You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/09/22 03:22:48 UTC

incubator-mynewt-newt git commit: newt - Print help when executed from non-proj dir.

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 327dfae4c -> 190713e59


newt - Print help when executed from non-proj dir.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/190713e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/190713e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/190713e5

Branch: refs/heads/develop
Commit: 190713e59f1b4c6895f6a48d174937a95c521dd3
Parents: 327dfae
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Sep 21 20:22:30 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Sep 21 20:22:30 2016 -0700

----------------------------------------------------------------------
 newt/cli/build_cmds.go   | 4 ++++
 newt/cli/complete_cmd.go | 3 +--
 newt/newt.go             | 6 +-----
 newt/project/project.go  | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/190713e5/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index a26deb7..08118cc 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -45,6 +45,10 @@ func testablePkgs() map[*pkg.LocalPackage]struct{} {
 
 	// Create a map of path => lclPkg.
 	proj := project.GetProject()
+	if proj == nil {
+		return nil
+	}
+
 	allPkgs := proj.PackagesOfType(-1)
 	pathLpkgMap := make(map[string]*pkg.LocalPackage, len(allPkgs))
 	for _, p := range allPkgs {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/190713e5/newt/cli/complete_cmd.go
----------------------------------------------------------------------
diff --git a/newt/cli/complete_cmd.go b/newt/cli/complete_cmd.go
index b2e83b6..68213da 100644
--- a/newt/cli/complete_cmd.go
+++ b/newt/cli/complete_cmd.go
@@ -34,10 +34,9 @@ import (
 )
 
 func targetList() []string {
-	err := project.Initialize()
-
 	targetNames := []string{}
 
+	err := project.Initialize()
 	if err != nil {
 		return targetNames
 	}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/190713e5/newt/newt.go
----------------------------------------------------------------------
diff --git a/newt/newt.go b/newt/newt.go
index f1e0c2d..7f9f244 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -121,7 +121,7 @@ func main() {
 	hold_lvl := log.GetLevel()
 	log.SetLevel(log.FatalLevel)
 
-	initErr := project.Initialize()
+	project.Initialize()
 
 	cli.AddCompleteCommands(cmd)
 	cli.AddProjectCommands(cmd)
@@ -148,10 +148,6 @@ func main() {
 		cmd.SilenceUsage = false
 	}
 
-	if initErr != nil {
-		cli.NewtUsage(nil, initErr)
-	}
-
 	log.SetLevel(hold_lvl)
 	cmd.Execute()
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/190713e5/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 29646e5..7daa694 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -100,7 +100,7 @@ func GetProject() *Project {
 		}
 		err = InitProject(wd)
 		if err != nil {
-			panic(err.Error())
+			return nil
 		}
 	}
 	return globalProject