Skip to content

Commit 8ff498b

Browse files
committed
general improvements for consistency between commands
1 parent aeb1528 commit 8ff498b

File tree

14 files changed

+50
-48
lines changed

14 files changed

+50
-48
lines changed

cli/burnbootloader/burnbootloader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewCommand() *cobra.Command {
4747
Long: tr("Upload the bootloader on the board using an external programmer."),
4848
Example: " " + os.Args[0] + " burn-bootloader -b arduino:avr:uno -P atmel_ice",
4949
Args: cobra.MaximumNArgs(1),
50-
Run: run,
50+
Run: runBootloaderCommand,
5151
}
5252

5353
fqbn.AddToCommand(burnBootloaderCommand)
@@ -61,7 +61,7 @@ func NewCommand() *cobra.Command {
6161
return burnBootloaderCommand
6262
}
6363

64-
func run(command *cobra.Command, args []string) {
64+
func runBootloaderCommand(command *cobra.Command, args []string) {
6565
instance := instance.CreateAndInit()
6666

6767
// We don't need a Sketch to upload a board's bootloader

cli/compile/compile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewCommand() *cobra.Command {
7676
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
7777
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property build.extra_flags=-DPIN=2 --build-property "compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n",
7878
Args: cobra.MaximumNArgs(1),
79-
Run: run,
79+
Run: runCompileCommand,
8080
}
8181

8282
fqbn.AddToCommand(compileCommand)
@@ -120,7 +120,7 @@ func NewCommand() *cobra.Command {
120120
return compileCommand
121121
}
122122

123-
func run(cmd *cobra.Command, args []string) {
123+
func runCompileCommand(cmd *cobra.Command, args []string) {
124124
inst := instance.CreateAndInit()
125125

126126
path := ""

cli/completion/completion.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ var (
3131

3232
// NewCommand created a new `completion` command
3333
func NewCommand() *cobra.Command {
34-
command := &cobra.Command{
34+
completionCommand := &cobra.Command{
3535
Use: "completion [bash|zsh|fish|powershell] [--no-descriptions]",
3636
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
3737
Args: cobra.ExactArgs(1),
3838
Short: tr("Generates completion scripts"),
3939
Long: tr("Generates completion scripts for various shells"),
4040
Example: " " + os.Args[0] + " completion bash > completion.sh\n" +
4141
" " + "source completion.sh",
42-
Run: run,
42+
Run: runCompletionCommand,
4343
}
44-
command.Flags().BoolVar(&completionNoDesc, "no-descriptions", false, tr("Disable completion description for shells that support it"))
44+
completionCommand.Flags().BoolVar(&completionNoDesc, "no-descriptions", false, tr("Disable completion description for shells that support it"))
4545

46-
return command
46+
return completionCommand
4747
}
4848

49-
func run(cmd *cobra.Command, args []string) {
49+
func runCompletionCommand(cmd *cobra.Command, args []string) {
5050
if completionNoDesc && (args[0] == "powershell") {
5151
feedback.Errorf(tr("Error: command description is not supported by %v"), args[0])
5252
os.Exit(errorcodes.ErrGeneric)

cli/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewCommand() *cobra.Command {
3636

3737
configCommand.AddCommand(initAddCommand())
3838
configCommand.AddCommand(initDeleteCommand())
39-
configCommand.AddCommand(initDumpCmd())
39+
configCommand.AddCommand(initDumpCommand())
4040
configCommand.AddCommand(initInitCommand())
4141
configCommand.AddCommand(initRemoveCommand())
4242
configCommand.AddCommand(initSetCommand())

cli/config/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func initDeleteCommand() *cobra.Command {
30-
addCommand := &cobra.Command{
30+
deleteCommand := &cobra.Command{
3131
Use: "delete",
3232
Short: tr("Deletes a settings key and all its sub keys."),
3333
Long: tr("Deletes a settings key and all its sub keys."),
@@ -40,7 +40,7 @@ func initDeleteCommand() *cobra.Command {
4040
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
4141
},
4242
}
43-
return addCommand
43+
return deleteCommand
4444
}
4545

4646
func runDeleteCommand(cmd *cobra.Command, args []string) {

cli/config/dump.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,21 @@ import (
2525
"gopkg.in/yaml.v2"
2626
)
2727

28-
func initDumpCmd() *cobra.Command {
29-
var dumpCmd = &cobra.Command{
28+
func initDumpCommand() *cobra.Command {
29+
var dumpCommand = &cobra.Command{
3030
Use: "dump",
3131
Short: tr("Prints the current configuration"),
3232
Long: tr("Prints the current configuration."),
3333
Example: " " + os.Args[0] + " config dump",
3434
Args: cobra.NoArgs,
3535
Run: runDumpCommand,
3636
}
37-
return dumpCmd
37+
return dumpCommand
38+
}
39+
40+
func runDumpCommand(cmd *cobra.Command, args []string) {
41+
logrus.Info("Executing `arduino config dump`")
42+
feedback.PrintResult(dumpResult{configuration.Settings.AllSettings()})
3843
}
3944

4045
// output from this command requires special formatting, let's create a dedicated
@@ -56,8 +61,3 @@ func (dr dumpResult) String() string {
5661

5762
return string(bs)
5863
}
59-
60-
func runDumpCommand(cmd *cobra.Command, args []string) {
61-
logrus.Info("Executing `arduino config dump`")
62-
feedback.PrintResult(dumpResult{configuration.Settings.AllSettings()})
63-
}

cli/config/remove.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
func initRemoveCommand() *cobra.Command {
29-
addCommand := &cobra.Command{
29+
removeCommand := &cobra.Command{
3030
Use: "remove",
3131
Short: tr("Removes one or more values from a setting."),
3232
Long: tr("Removes one or more values from a setting."),
@@ -39,7 +39,7 @@ func initRemoveCommand() *cobra.Command {
3939
return GetConfigurationKeys(), cobra.ShellCompDirectiveDefault
4040
},
4141
}
42-
return addCommand
42+
return removeCommand
4343
}
4444

4545
func runRemoveCommand(cmd *cobra.Command, args []string) {

cli/config/set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func initSetCommand() *cobra.Command {
30-
addCommand := &cobra.Command{
30+
setCommand := &cobra.Command{
3131
Use: "set",
3232
Short: tr("Sets a setting value."),
3333
Long: tr("Sets a setting value."),
@@ -42,7 +42,7 @@ func initSetCommand() *cobra.Command {
4242
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
4343
},
4444
}
45-
return addCommand
45+
return setCommand
4646
}
4747

4848
func runSetCommand(cmd *cobra.Command, args []string) {

cli/core/uninstall.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
func initUninstallCommand() *cobra.Command {
35-
return &cobra.Command{
35+
uninstallCommand := &cobra.Command{
3636
Use: fmt.Sprintf("uninstall %s:%s ...", tr("PACKAGER"), tr("ARCH")),
3737
Short: tr("Uninstalls one or more cores and corresponding tool dependencies if no longer used."),
3838
Long: tr("Uninstalls one or more cores and corresponding tool dependencies if no longer used."),
@@ -43,6 +43,7 @@ func initUninstallCommand() *cobra.Command {
4343
return arguments.GetUninstallableCores(), cobra.ShellCompDirectiveDefault
4444
},
4545
}
46+
return uninstallCommand
4647
}
4748

4849
func runUninstallCommand(cmd *cobra.Command, args []string) {

cli/daemon/daemon.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ var (
5050

5151
// NewCommand created a new `daemon` command
5252
func NewCommand() *cobra.Command {
53-
cmd := &cobra.Command{
53+
daemonCommand := &cobra.Command{
5454
Use: "daemon",
5555
Short: tr("Run as a daemon on port: %s", configuration.Settings.GetString("daemon.port")),
5656
Long: tr("Running as a daemon the initialization of cores and libraries is done only once."),
5757
Example: " " + os.Args[0] + " daemon",
5858
Args: cobra.NoArgs,
5959
Run: runDaemonCommand,
6060
}
61-
cmd.PersistentFlags().String("port", "", tr("The TCP port the daemon will listen to"))
62-
configuration.Settings.BindPFlag("daemon.port", cmd.PersistentFlags().Lookup("port"))
63-
cmd.Flags().BoolVar(&daemonize, "daemonize", false, tr("Do not terminate daemon process if the parent process dies"))
64-
cmd.Flags().BoolVar(&debug, "debug", false, tr("Enable debug logging of gRPC calls"))
65-
cmd.Flags().StringSliceVar(&debugFilters, "debug-filter", []string{}, tr("Display only the provided gRPC calls"))
66-
return cmd
61+
daemonCommand.PersistentFlags().String("port", "", tr("The TCP port the daemon will listen to"))
62+
configuration.Settings.BindPFlag("daemon.port", daemonCommand.PersistentFlags().Lookup("port"))
63+
daemonCommand.Flags().BoolVar(&daemonize, "daemonize", false, tr("Do not terminate daemon process if the parent process dies"))
64+
daemonCommand.Flags().BoolVar(&debug, "debug", false, tr("Enable debug logging of gRPC calls"))
65+
daemonCommand.Flags().StringSliceVar(&debugFilters, "debug-filter", []string{}, tr("Display only the provided gRPC calls"))
66+
return daemonCommand
6767
}
6868

6969
func runDaemonCommand(cmd *cobra.Command, args []string) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy