Skip to content

Commit

Permalink
add sub sub commands
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Downs <[email protected]>
  • Loading branch information
briandowns committed Jan 11, 2024
1 parent 22877f2 commit d074530
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions cmd/release/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"html/template"
"os"

"github.com/spf13/cobra"
Expand All @@ -18,32 +17,43 @@ var configCmd = &cobra.Command{
rootCmd.Help()
os.Exit(0)
}
},
}

switch args[0] {
case "generate":
//
case "view":
tmpl, err := template.New("config").Parse(configViewTemplate)
if err != nil {
fmt.Println(err)
os.Exit(0)
}
if err := tmpl.Execute(os.Stdout, rootConfig); err != nil {
fmt.Println(err)
os.Exit(0)
}
case "edit":
//
default:
rootCmd.Help()
os.Exit(0)
}
var genConfigSubCmd = &cobra.Command{
Use: "gen",
Short: "generate config",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Here we are!")
},
}

var viewConfigSubCmd = &cobra.Command{
Use: "view",
Short: "view config",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Here we are!")
},
}

var editConfigSubCmd = &cobra.Command{
Use: "edit",
Short: "edit config",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Here we are!")
},
}

func init() {
rootCmd.AddCommand(configCmd)

configCmd.AddCommand(genConfigSubCmd)
configCmd.AddCommand(viewConfigSubCmd)
configCmd.AddCommand(editConfigSubCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
Expand Down
Binary file modified cmd/release/release
Binary file not shown.

0 comments on commit d074530

Please sign in to comment.