You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/03/11 22:24:33 UTC
incubator-mynewt-newt git commit: add newt new command
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop f74590d09 -> b5850ea23
add newt new command
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/b5850ea2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/b5850ea2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/b5850ea2
Branch: refs/heads/develop
Commit: b5850ea2318d8e4b97d931ec007b87796e8f3b16
Parents: f74590d
Author: Sterling Hughes <st...@apache.org>
Authored: Fri Mar 11 13:24:20 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Fri Mar 11 13:24:31 2016 -0800
----------------------------------------------------------------------
newt/cli/project_cmds.go | 48 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b5850ea2/newt/cli/project_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index 4392a95..e5df0aa 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -21,14 +21,50 @@ package cli
import (
"fmt"
+ "os"
"github.com/spf13/cobra"
+ "mynewt.apache.org/newt/newt/downloader"
"mynewt.apache.org/newt/newt/interfaces"
"mynewt.apache.org/newt/newt/project"
+ "mynewt.apache.org/newt/util"
)
var projectForce bool = false
+func newRunCmd(cmd *cobra.Command, args []string) {
+ if len(args) < 1 {
+ NewtUsage(cmd, util.NewNewtError("Must specify "+
+ "a project directory to newt new"))
+ }
+
+ newDir := args[0]
+
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "Downloading "+
+ "project skeleton from apache/incubator-mynewt-blinky...\n")
+ dl := downloader.NewGithubDownloader()
+ dl.User = "apache"
+ dl.Repo = "incubator-mynewt-blinky"
+
+ dir, err := dl.DownloadRepo("develop")
+ if err != nil {
+ NewtUsage(cmd, err)
+ }
+
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "Installing "+
+ "skeleton in %s...\n", newDir)
+
+ if err := util.CopyDir(dir, newDir); err != nil {
+ NewtUsage(cmd, err)
+ }
+
+ if err := os.RemoveAll(newDir + "/" + "/.git/"); err != nil {
+ NewtUsage(cmd, err)
+ }
+
+ fmt.Printf("Project %s successfully created\n", newDir)
+}
+
func installRunCmd(cmd *cobra.Command, args []string) {
if err := project.Initialize(); err != nil {
NewtUsage(cmd, err)
@@ -87,4 +123,16 @@ func AddProjectCommands(cmd *cobra.Command) {
cmd.AddCommand(upgradeCmd)
+ newHelpText := ""
+ newHelpEx := ""
+ newCmd := &cobra.Command{
+ Use: "new",
+ Short: "Create a new project",
+ Long: newHelpText,
+ Example: newHelpEx,
+ Run: newRunCmd,
+ }
+
+ cmd.AddCommand(newCmd)
+
}