Skip to content

Commit 86fecf2

Browse files
author
Roberto Sora
committed
replace cli.AppName with global variable global.GetAppName() getter
1 parent 83d1ce7 commit 86fecf2

37 files changed

+84
-63
lines changed

cli/arduino-cli.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
board_manager:
2+
additional_urls:

cli/board/attach.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package board
1919

2020
import (
2121
"context"
22+
"github.com/arduino/arduino-cli/global"
2223
"os"
2324

2425
"github.com/arduino/arduino-cli/cli"
@@ -33,9 +34,9 @@ func initAttachCommand() *cobra.Command {
3334
Use: "attach <port>|<FQBN> [sketchPath]",
3435
Short: "Attaches a sketch to a board.",
3536
Long: "Attaches a sketch to a board.",
36-
Example: " " + cli.AppName + " board attach serial:///dev/tty/ACM0\n" +
37-
" " + cli.AppName + " board attach serial:///dev/tty/ACM0 HelloWorld\n" +
38-
" " + cli.AppName + " board attach arduino:samd:mkr1000",
37+
Example: " " + global.GetAppName() + " board attach serial:///dev/tty/ACM0\n" +
38+
" " + global.GetAppName() + " board attach serial:///dev/tty/ACM0 HelloWorld\n" +
39+
" " + global.GetAppName() + " board attach arduino:samd:mkr1000",
3940
Args: cobra.RangeArgs(1, 2),
4041
Run: runAttachCommand,
4142
}

cli/board/board.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package board
1919

2020
import (
21-
"github.com/arduino/arduino-cli/cli"
21+
"github.com/arduino/arduino-cli/global"
2222
"github.com/spf13/cobra"
2323
)
2424

@@ -29,9 +29,9 @@ func InitCommand() *cobra.Command {
2929
Short: "Arduino board commands.",
3030
Long: "Arduino board commands.",
3131
Example: " # Lists all connected boards.\n" +
32-
" " + cli.AppName + " board list\n\n" +
32+
" " + global.GetAppName() + " board list\n\n" +
3333
" # Attaches a sketch to a board.\n" +
34-
" " + cli.AppName + " board attach serial:///dev/tty/ACM0 mySketch",
34+
" " + global.GetAppName() + " board attach serial:///dev/tty/ACM0 mySketch",
3535
}
3636
boardCommand.AddCommand(initAttachCommand())
3737
boardCommand.AddCommand(initDetailsCommand())

cli/board/details.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package board
2020
import (
2121
"context"
2222
"fmt"
23+
"github.com/arduino/arduino-cli/global"
2324
"os"
2425

2526
"github.com/arduino/arduino-cli/cli"
@@ -35,7 +36,7 @@ func initDetailsCommand() *cobra.Command {
3536
Use: "details <FQBN>",
3637
Short: "Print details about a board.",
3738
Long: "Show information about a board, in particular if the board has options to be specified in the FQBN.",
38-
Example: " " + cli.AppName + " board details arduino:avr:nano",
39+
Example: " " + global.GetAppName() + " board details arduino:avr:nano",
3940
Args: cobra.ExactArgs(1),
4041
Run: runDetailsCommand,
4142
}

cli/board/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package board
2020
import (
2121
"context"
2222
"fmt"
23+
"github.com/arduino/arduino-cli/global"
2324
"os"
2425
"sort"
2526
"time"
@@ -37,7 +38,7 @@ func initListCommand() *cobra.Command {
3738
Use: "list",
3839
Short: "List connected boards.",
3940
Long: "Detects and displays a list of connected boards to the current computer.",
40-
Example: " " + cli.AppName + " board list --timeout 10s",
41+
Example: " " + global.GetAppName() + " board list --timeout 10s",
4142
Args: cobra.NoArgs,
4243
Run: runListCommand,
4344
}

cli/board/listall.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package board
2020
import (
2121
"context"
2222
"fmt"
23+
"github.com/arduino/arduino-cli/global"
2324
"os"
2425
"sort"
2526

@@ -39,8 +40,8 @@ func initListAllCommand() *cobra.Command {
3940
"List all boards that have the support platform installed. You can search\n" +
4041
"for a specific board if you specify the board name",
4142
Example: "" +
42-
" " + cli.AppName + " board listall\n" +
43-
" " + cli.AppName + " board listall zero",
43+
" " + global.GetAppName() + " board listall\n" +
44+
" " + global.GetAppName() + " board listall zero",
4445
Args: cobra.ArbitraryArgs,
4546
Run: runListAllCommand,
4647
}

cli/cli.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ package cli
2020
import (
2121
"context"
2222
"errors"
23-
"os"
24-
"path/filepath"
25-
2623
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2724
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
2825
"github.com/arduino/arduino-cli/commands"
2926
"github.com/arduino/arduino-cli/common/formatter"
3027
"github.com/arduino/arduino-cli/configs"
28+
"github.com/arduino/arduino-cli/global"
3129
"github.com/arduino/arduino-cli/rpc"
32-
paths "github.com/arduino/go-paths-helper"
30+
"github.com/arduino/go-paths-helper"
3331
"github.com/sirupsen/logrus"
32+
"os"
3433
)
3534

3635
// Error codes to be used for os.Exit().
@@ -61,9 +60,6 @@ var GlobalFlags struct {
6160
OutputJSON bool // true output in JSON, false output as Text
6261
}
6362

64-
// AppName is the command line name of the Arduino CLI executable
65-
var AppName = filepath.Base(os.Args[0])
66-
6763
var Config *configs.Configuration
6864

6965
func packageManagerInitReq() *rpc.InitReq {
@@ -116,7 +112,7 @@ func CreateInstance() *rpc.Instance {
116112
for _, err := range resp.GetPlatformsIndexErrors() {
117113
formatter.PrintError(errors.New(err), "Error loading index")
118114
}
119-
formatter.PrintErrorMessage("Launch '" + AppName + " core update-index' to fix or download indexes.")
115+
formatter.PrintErrorMessage("Launch '" + global.GetAppName() + " core update-index' to fix or download indexes.")
120116
os.Exit(ErrGeneric)
121117
}
122118
return resp.GetInstance()

cli/compile/compile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package compile
1919

2020
import (
2121
"context"
22+
"github.com/arduino/arduino-cli/global"
2223
"os"
2324

2425
"github.com/arduino/arduino-cli/cli"
@@ -35,7 +36,7 @@ func InitCommand() *cobra.Command {
3536
Use: "compile",
3637
Short: "Compiles Arduino sketches.",
3738
Long: "Compiles Arduino sketches.",
38-
Example: " " + cli.AppName + " compile -b arduino:avr:uno /home/user/Arduino/MySketch",
39+
Example: " " + global.GetAppName() + " compile -b arduino:avr:uno /home/user/Arduino/MySketch",
3940
Args: cobra.MaximumNArgs(1),
4041
Run: run,
4142
}

cli/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package config
1919

2020
import (
21-
"github.com/arduino/arduino-cli/cli"
21+
"github.com/arduino/arduino-cli/global"
2222
"github.com/spf13/cobra"
2323
)
2424

@@ -27,7 +27,7 @@ func InitCommand() *cobra.Command {
2727
configCommand := &cobra.Command{
2828
Use: "config",
2929
Short: "Arduino Configuration Commands.",
30-
Example: " " + cli.AppName + " config init",
30+
Example: " " + global.GetAppName() + " config init",
3131
}
3232
configCommand.AddCommand(initDumpCommand())
3333
configCommand.AddCommand(initInitCommand())

cli/config/dump.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package config
1919

2020
import (
2121
"fmt"
22+
"github.com/arduino/arduino-cli/global"
2223
"os"
2324

2425
"github.com/arduino/arduino-cli/cli"
@@ -32,7 +33,7 @@ func initDumpCommand() *cobra.Command {
3233
Use: "dump",
3334
Short: "Prints the current configuration",
3435
Long: "Prints the current configuration.",
35-
Example: " " + cli.AppName + " config dump",
36+
Example: " " + global.GetAppName() + " config dump",
3637
Args: cobra.NoArgs,
3738
Run: runDumpCommand,
3839
}

0 commit comments

Comments
 (0)