Skip to content

Commit a7fe054

Browse files
author
Roberto Sora
committed
replace cli.AppName with global variable global.GetAppName() getter
1 parent 7d9e1c1 commit a7fe054

38 files changed

+91
-64
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/core/core.go

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

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

@@ -28,7 +28,7 @@ func InitCommand() *cobra.Command {
2828
Use: "core",
2929
Short: "Arduino Core operations.",
3030
Long: "Arduino Core operations.",
31-
Example: " " + cli.AppName + " core update-index",
31+
Example: " " + global.GetAppName() + " core update-index",
3232
}
3333
coreCommand.AddCommand(initDownloadCommand())
3434
coreCommand.AddCommand(initInstallCommand())

cli/core/download.go

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

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

2425
"github.com/arduino/arduino-cli/cli"
@@ -35,8 +36,8 @@ func initDownloadCommand() *cobra.Command {
3536
Short: "Downloads one or more cores and corresponding tool dependencies.",
3637
Long: "Downloads one or more cores and corresponding tool dependencies.",
3738
Example: "" +
38-
" " + cli.AppName + " core download arduino:samd # to download the latest version of arduino SAMD core.\n" +
39-
" " + cli.AppName + " core download arduino:samd=1.6.9 # for a specific version (in this case 1.6.9).",
39+
" " + global.GetAppName() + " core download arduino:samd # to download the latest version of arduino SAMD core.\n" +
40+
" " + global.GetAppName() + " core download arduino:samd=1.6.9 # for a specific version (in this case 1.6.9).",
4041
Args: cobra.MinimumNArgs(1),
4142
Run: runDownloadCommand,
4243
}

cli/core/install.go

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

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

2425
"github.com/arduino/arduino-cli/cli"
@@ -35,9 +36,9 @@ func initInstallCommand() *cobra.Command {
3536
Short: "Installs one or more cores and corresponding tool dependencies.",
3637
Long: "Installs one or more cores and corresponding tool dependencies.",
3738
Example: " # download the latest version of arduino SAMD core.\n" +
38-
" " + cli.AppName + " core install arduino:samd\n\n" +
39+
" " + global.GetAppName() + " core install arduino:samd\n\n" +
3940
" # download a specific version (in this case 1.6.9).\n" +
40-
" " + cli.AppName + " core install arduino:samd=1.6.9",
41+
" " + global.GetAppName() + " core install arduino:samd=1.6.9",
4142
Args: cobra.MinimumNArgs(1),
4243
Run: runInstallCommand,
4344
}

cli/core/list.go

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

@@ -37,7 +38,7 @@ func initListCommand() *cobra.Command {
3738
Use: "list",
3839
Short: "Shows the list of installed platforms.",
3940
Long: "Shows the list of installed platforms.",
40-
Example: " " + cli.AppName + " core list",
41+
Example: " " + global.GetAppName() + " core list",
4142
Args: cobra.NoArgs,
4243
Run: runListCommand,
4344
}

cli/core/search.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package core
2020
import (
2121
"context"
2222
"fmt"
23+
"github.com/arduino/arduino-cli/global"
2324
"os"
2425
"sort"
2526
"strings"
@@ -38,7 +39,7 @@ func initSearchCommand() *cobra.Command {
3839
Use: "search <keywords...>",
3940
Short: "Search for a core in the package index.",
4041
Long: "Search for a core in the package index using the specified keywords.",
41-
Example: " " + cli.AppName + " core search MKRZero -v",
42+
Example: " " + global.GetAppName() + " core search MKRZero -v",
4243
Args: cobra.MinimumNArgs(1),
4344
Run: runSearchCommand,
4445
}

cli/core/uninstall.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package core
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 initUninstallCommand() *cobra.Command {
3536
Use: "uninstall PACKAGER:ARCH ...",
3637
Short: "Uninstalls one or more cores and corresponding tool dependencies if no more used.",
3738
Long: "Uninstalls one or more cores and corresponding tool dependencies if no more used.",
38-
Example: " " + cli.AppName + " core uninstall arduino:samd\n",
39+
Example: " " + global.GetAppName() + " core uninstall arduino:samd\n",
3940
Args: cobra.MinimumNArgs(1),
4041
Run: runUninstallCommand,
4142
}

cli/core/update_index.go

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

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

2425
"github.com/arduino/arduino-cli/cli"
@@ -34,7 +35,7 @@ func initUpdateIndexCommand() *cobra.Command {
3435
Use: "update-index",
3536
Short: "Updates the index of cores.",
3637
Long: "Updates the index of cores to the latest version.",
37-
Example: " " + cli.AppName + " core update-index",
38+
Example: " " + global.GetAppName() + " core update-index",
3839
Args: cobra.NoArgs,
3940
Run: runUpdateIndexCommand,
4041
}

cli/core/upgrade.go

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

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

2425
"github.com/arduino/arduino-cli/cli"
@@ -36,9 +37,9 @@ func initUpgradeCommand() *cobra.Command {
3637
Long: "Upgrades one or all installed platforms to the latest version.",
3738
Example: "" +
3839
" # upgrade everything to the latest version\n" +
39-
" " + cli.AppName + " core upgrade\n\n" +
40+
" " + global.GetAppName() + " core upgrade\n\n" +
4041
" # upgrade arduino:samd to the latest version\n" +
41-
" " + cli.AppName + " core upgrade arduino:samd",
42+
" " + global.GetAppName() + " core upgrade arduino:samd",
4243
Run: runUpgradeCommand,
4344
}
4445
return upgradeCommand

cli/daemon/daemon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package daemon
1919

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

25-
"github.com/arduino/arduino-cli/cli"
2626
"github.com/arduino/arduino-cli/daemon"
2727
"github.com/arduino/arduino-cli/rpc"
2828
"github.com/spf13/cobra"
@@ -35,7 +35,7 @@ func InitCommand() *cobra.Command {
3535
Use: "daemon",
3636
Short: "Run as a daemon",
3737
Long: "Running as a daemon the initialization of cores and libraries is done only once.",
38-
Example: " " + cli.AppName + " daemon",
38+
Example: " " + global.GetAppName() + " daemon",
3939
Args: cobra.NoArgs,
4040
Run: runDaemonCommand,
4141
Hidden: true,

cli/lib/download.go

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

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

2425
"github.com/arduino/arduino-cli/common/formatter"
@@ -36,8 +37,8 @@ func initDownloadCommand() *cobra.Command {
3637
Short: "Downloads one or more libraries without installing them.",
3738
Long: "Downloads one or more libraries without installing them.",
3839
Example: "" +
39-
" " + cli.AppName + " lib download AudioZero # for the latest version.\n" +
40-
" " + cli.AppName + " lib download AudioZero@1.0.0 # for a specific version.",
40+
" " + global.GetAppName() + " lib download AudioZero # for the latest version.\n" +
41+
" " + global.GetAppName() + " lib download AudioZero@1.0.0 # for a specific version.",
4142
Args: cobra.MinimumNArgs(1),
4243
Run: runDownloadCommand,
4344
}

cli/lib/install.go

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

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

2425
"github.com/arduino/arduino-cli/commands/lib"
@@ -36,8 +37,8 @@ func initInstallCommand() *cobra.Command {
3637
Short: "Installs one of more specified libraries into the system.",
3738
Long: "Installs one or more specified libraries into the system.",
3839
Example: "" +
39-
" " + cli.AppName + " lib install AudioZero # for the latest version.\n" +
40-
" " + cli.AppName + " lib install AudioZero@1.0.0 # for the specific version.",
40+
" " + global.GetAppName() + " lib install AudioZero # for the latest version.\n" +
41+
" " + global.GetAppName() + " lib install AudioZero@1.0.0 # for the specific version.",
4142
Args: cobra.MinimumNArgs(1),
4243
Run: runInstallCommand,
4344
}

cli/lib/lib.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package lib
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,8 +29,8 @@ func InitCommand() *cobra.Command {
2929
Short: "Arduino commands about libraries.",
3030
Long: "Arduino commands about libraries.",
3131
Example: "" +
32-
" " + cli.AppName + " lib install AudioZero\n" +
33-
" " + cli.AppName + " lib update-index",
32+
" " + global.GetAppName() + " lib install AudioZero\n" +
33+
" " + global.GetAppName() + " lib update-index",
3434
}
3535
libCommand.AddCommand(initDownloadCommand())
3636
libCommand.AddCommand(initInstallCommand())

cli/lib/list.go

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

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

2425
"github.com/arduino/arduino-cli/cli"
@@ -36,7 +37,7 @@ func initListCommand() *cobra.Command {
3637
Use: "list",
3738
Short: "Shows a list of all installed libraries.",
3839
Long: "Shows a list of all installed libraries.",
39-
Example: " " + cli.AppName + " lib list",
40+
Example: " " + global.GetAppName() + " lib list",
4041
Args: cobra.NoArgs,
4142
Run: runListCommand,
4243
}

0 commit comments

Comments
 (0)