Skip to content

Commit 17aa937

Browse files
committed
split function for testing sake
1 parent f179a91 commit 17aa937

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Diff for: cli/cli.go

+18-13
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,25 @@ var (
5959

6060
// Init the cobra root command
6161
func init() {
62-
ArduinoCli.AddCommand(board.NewCommand())
63-
ArduinoCli.AddCommand(compile.NewCommand())
64-
ArduinoCli.AddCommand(config.NewCommand())
65-
ArduinoCli.AddCommand(core.NewCommand())
66-
ArduinoCli.AddCommand(daemon.NewCommand())
67-
ArduinoCli.AddCommand(generatedocs.NewCommand())
68-
ArduinoCli.AddCommand(lib.NewCommand())
69-
ArduinoCli.AddCommand(sketch.NewCommand())
70-
ArduinoCli.AddCommand(upload.NewCommand())
71-
ArduinoCli.AddCommand(version.NewCommand())
62+
createCliCommandTree(ArduinoCli)
63+
}
64+
65+
// this is here only for testing
66+
func createCliCommandTree(cmd *cobra.Command) {
67+
cmd.AddCommand(board.NewCommand())
68+
cmd.AddCommand(compile.NewCommand())
69+
cmd.AddCommand(config.NewCommand())
70+
cmd.AddCommand(core.NewCommand())
71+
cmd.AddCommand(daemon.NewCommand())
72+
cmd.AddCommand(generatedocs.NewCommand())
73+
cmd.AddCommand(lib.NewCommand())
74+
cmd.AddCommand(sketch.NewCommand())
75+
cmd.AddCommand(upload.NewCommand())
76+
cmd.AddCommand(version.NewCommand())
7277

73-
ArduinoCli.PersistentFlags().BoolVar(&globals.Debug, "debug", false, "Enables debug output (super verbose, used to debug the CLI).")
74-
ArduinoCli.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be [text|json].")
75-
ArduinoCli.PersistentFlags().StringVar(&globals.YAMLConfigFile, "config-file", "", "The custom config file (if not specified the default will be used).")
78+
cmd.PersistentFlags().BoolVar(&globals.Debug, "debug", false, "Enables debug output (super verbose, used to debug the CLI).")
79+
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be [text|json].")
80+
cmd.PersistentFlags().StringVar(&globals.YAMLConfigFile, "config-file", "", "The custom config file (if not specified the default will be used).")
7681
}
7782

7883
func preRun(cmd *cobra.Command, args []string) {

0 commit comments

Comments
 (0)