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/03/14 01:03:14 UTC
incubator-mynewt-newt git commit: Replace pkg command with "project"
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop 655f5a3ea -> d97b1511a
Replace pkg command with "project"
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/d97b1511
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/d97b1511
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/d97b1511
Branch: refs/heads/develop
Commit: d97b1511ab5014e62b0af4372046094af0ddc65e
Parents: 655f5a3
Author: Christopher Collins <cc...@apache.org>
Authored: Sun Mar 13 17:03:08 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sun Mar 13 17:03:08 2016 -0700
----------------------------------------------------------------------
newt/cli/package_cmds.go | 77 ---------------------------------------
newt/cli/project_cmds.go | 83 +++++++++++++++++++++++++++++++++++++++++++
newt/cli/target_cmds.go | 2 +-
newt/newt.go | 1 -
4 files changed, 84 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d97b1511/newt/cli/package_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/package_cmds.go b/newt/cli/package_cmds.go
deleted file mode 100644
index 058bfeb..0000000
--- a/newt/cli/package_cmds.go
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package cli
-
-import (
- "sort"
-
- "github.com/spf13/cobra"
- "mynewt.apache.org/newt/newt/pkg"
- "mynewt.apache.org/newt/newt/project"
- "mynewt.apache.org/newt/util"
-)
-
-func packageListCmd(cmd *cobra.Command, args []string) {
- packNames := []string{}
- repoHash := project.GetProject().PackageList()
- for _, pkgHash := range repoHash {
- for _, pack := range *pkgHash {
- if pack.Type() != pkg.PACKAGE_TYPE_TARGET {
- packNames = append(packNames, pack.FullName())
- }
- }
- }
-
- sort.Strings(packNames)
-
- util.StatusMessage(util.VERBOSITY_DEFAULT, "Packages in this project:\n")
- for _, name := range packNames {
- util.StatusMessage(util.VERBOSITY_DEFAULT, " * %s\n", name)
- }
-}
-
-func AddPackageCommands(cmd *cobra.Command) {
- packageHelpText := ""
- packageHelpEx := ""
- packageCmd := &cobra.Command{
- Use: "pkg",
- Short: "Command for manipulating packages",
- Long: packageHelpText,
- Example: packageHelpEx,
- Run: func(cmd *cobra.Command, args []string) {
- cmd.Usage()
- },
- }
-
- cmd.AddCommand(packageCmd)
-
- listHelpText := "List all packages in the project."
- listHelpEx := " newt pkg list\n"
-
- listCmd := &cobra.Command{
- Use: "list",
- Short: "List all packages",
- Long: listHelpText,
- Example: listHelpEx,
- Run: packageListCmd,
- }
-
- packageCmd.AddCommand(listCmd)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d97b1511/newt/cli/project_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index e5df0aa..2d7dec3 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -22,6 +22,8 @@ package cli
import (
"fmt"
"os"
+ "sort"
+ "strings"
"github.com/spf13/cobra"
"mynewt.apache.org/newt/newt/downloader"
@@ -93,6 +95,60 @@ func upgradeRunCmd(cmd *cobra.Command, args []string) {
fmt.Println("Repos successfully upgrade")
}
+func showRunCmd(cmd *cobra.Command, args []string) {
+ reqRepoName := ""
+ if len(args) >= 1 {
+ reqRepoName = strings.TrimPrefix(args[0], "@")
+ }
+
+ if err := project.Initialize(); err != nil {
+ NewtUsage(nil, err)
+ }
+ proj := project.GetProject()
+
+ repoNames := []string{}
+ for repoName, _ := range proj.PackageList() {
+ repoNames = append(repoNames, repoName)
+ }
+ sort.Strings(repoNames)
+
+ if reqRepoName == "" {
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "Repositories in %s:\n",
+ proj.Name())
+
+ for _, repoName := range repoNames {
+ util.StatusMessage(util.VERBOSITY_DEFAULT, " * @%s\n", repoName)
+ }
+
+ // Now display the packages in the local repository.
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "\n")
+ reqRepoName = "local"
+ }
+
+ firstRepo := true
+ for _, repoName := range repoNames {
+ if reqRepoName == "all" || reqRepoName == repoName {
+ packNames := []string{}
+ for _, pack := range *proj.PackageList()[repoName] {
+ packNames = append(packNames, pack.Name())
+ }
+
+ sort.Strings(packNames)
+ if !firstRepo {
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "\n")
+ } else {
+ firstRepo = false
+ }
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "Packages in @%s:\n",
+ repoName)
+ for _, pkgName := range packNames {
+ util.StatusMessage(util.VERBOSITY_DEFAULT, " * %s\n",
+ pkgName)
+ }
+ }
+ }
+}
+
func AddProjectCommands(cmd *cobra.Command) {
installHelpText := ""
installHelpEx := ""
@@ -135,4 +191,31 @@ func AddProjectCommands(cmd *cobra.Command) {
cmd.AddCommand(newCmd)
+ // Top level project command.
+ projectHelpText := ""
+ projectHelpEx := ""
+ projectCmd := &cobra.Command{
+ Use: "project",
+ Short: "Display information about your project",
+ Long: projectHelpText,
+ Example: projectHelpEx,
+ Run: func(cmd *cobra.Command, args []string) {
+ cmd.Usage()
+ },
+ }
+
+ cmd.AddCommand(projectCmd)
+
+ showHelpText := "Show information about the project."
+ showHelpEx := " newt pkg show\n"
+
+ showCmd := &cobra.Command{
+ Use: "show [repo-name|all]",
+ Short: "Show project info",
+ Long: showHelpText,
+ Example: showHelpEx,
+ Run: showRunCmd,
+ }
+
+ projectCmd.AddCommand(showCmd)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d97b1511/newt/cli/target_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index f25e22d..6dba037 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -445,7 +445,7 @@ func AddTargetCommands(cmd *cobra.Command) {
targetCmd.AddCommand(delCmd)
- copyHelpText := "Creates a new target by cloning <src-target>."
+ copyHelpText := "Create a new target by cloning <src-target>."
copyHelpEx := " newt target copy <src-target> <dst-target>\n"
copyHelpEx += " newt target copy blinky_sim my_target"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d97b1511/newt/newt.go
----------------------------------------------------------------------
diff --git a/newt/newt.go b/newt/newt.go
index f85ac2e..13516bd 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -114,7 +114,6 @@ func main() {
cli.AddBuildCommands(cmd)
cli.AddImageCommands(cmd)
cli.AddRunCommands(cmd)
- cli.AddPackageCommands(cmd)
cmd.Execute()
}