Skip to content

Commit

Permalink
try to implement subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Sep 7, 2017
1 parent f48ca80 commit 899699a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd
import (
"fmt"

"github.com/gosuri/cmdns"
"github.com/spf13/cobra"
)

Expand All @@ -34,8 +35,16 @@ to quickly create a Cobra application.`,
fmt.Println("apps called")
},
}
var infoSubcmd = &cobra.Command{
Use: "info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("apps:info called")
},
}

func init() {
appsCmd.AddCommand(infoSubcmd)
cmdns.Namespace(appsCmd)
RootCmd.AddCommand(appsCmd)

// Here you will define your flags and configuration settings.
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"os"

"github.com/gosuri/cmdns"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -43,6 +44,7 @@ to quickly create a Cobra application.`,
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cmdns.Namespace(RootCmd)
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down

0 comments on commit 899699a

Please sign in to comment.