Skip to content

Commit bdaa6ab

Browse files
committed
moved flags from root to export cmd
1 parent e396fd4 commit bdaa6ab

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

cmd/export.go

+7
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ var exportCmd = &cobra.Command{
118118
func init() {
119119
rootCmd.AddCommand(exportCmd)
120120

121+
exportCmd.Flags().StringSliceP("yang-dir", "y", []string{"./"}, "directory(-ies) with YANG modules. Values can be provided multiple times (-y dir1 -y dir2)")
122+
viper.BindPFlag("yang-dir", rootCmd.PersistentFlags().Lookup("yang-dir"))
123+
124+
exportCmd.Flags().StringP("module", "m", "", "path to the YANG file to use for path export (required)")
125+
viper.BindPFlag("module", rootCmd.PersistentFlags().Lookup("module"))
126+
exportCmd.MarkFlagRequired("module")
127+
121128
exportCmd.Flags().StringP("format", "f", "text", "paths output format. One of [text, html]")
122129
viper.BindPFlag("path-format", exportCmd.Flags().Lookup("format"))
123130

cmd/root.go

-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"os"
2020

2121
"github.com/spf13/cobra"
22-
"github.com/spf13/viper"
2322
)
2423

2524
// rootCmd represents the base command when called without any subcommands
@@ -39,14 +38,4 @@ func Execute() {
3938

4039
func init() {
4140
rootCmd.SilenceUsage = true
42-
43-
rootCmd.PersistentFlags().StringSliceP("yang-dir", "y", []string{"./"}, "directory(-ies) with YANG modules. Values can be provided multiple times (-y dir1 -y dir2)")
44-
viper.BindPFlag("yang-dir", rootCmd.PersistentFlags().Lookup("yang-dir"))
45-
46-
// rootCmd.PersistentFlags().BoolP("debug", "d", false, "debug")
47-
// viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug"))
48-
49-
rootCmd.PersistentFlags().StringP("module", "m", "", "path to the YANG file to use for path export (required)")
50-
viper.BindPFlag("module", rootCmd.PersistentFlags().Lookup("module"))
51-
rootCmd.MarkPersistentFlagRequired("module")
5241
}

0 commit comments

Comments
 (0)