Skip to content

Global build vars #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/cmd/formatter/debug.test
/arduino-cli.yaml
/wiki
.idea
7 changes: 4 additions & 3 deletions cli/board/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/spf13/cobra"
)
Expand All @@ -33,9 +34,9 @@ func initAttachCommand() *cobra.Command {
Use: "attach <port>|<FQBN> [sketchPath]",
Short: "Attaches a sketch to a board.",
Long: "Attaches a sketch to a board.",
Example: " " + cli.AppName + " board attach serial:///dev/tty/ACM0\n" +
" " + cli.AppName + " board attach serial:///dev/tty/ACM0 HelloWorld\n" +
" " + cli.AppName + " board attach arduino:samd:mkr1000",
Example: " " + global.GetAppName() + " board attach serial:///dev/tty/ACM0\n" +
" " + global.GetAppName() + " board attach serial:///dev/tty/ACM0 HelloWorld\n" +
" " + global.GetAppName() + " board attach arduino:samd:mkr1000",
Args: cobra.RangeArgs(1, 2),
Run: runAttachCommand,
}
Expand Down
6 changes: 3 additions & 3 deletions cli/board/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package board

import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/global"
"github.com/spf13/cobra"
)

Expand All @@ -29,9 +29,9 @@ func InitCommand() *cobra.Command {
Short: "Arduino board commands.",
Long: "Arduino board commands.",
Example: " # Lists all connected boards.\n" +
" " + cli.AppName + " board list\n\n" +
" " + global.GetAppName() + " board list\n\n" +
" # Attaches a sketch to a board.\n" +
" " + cli.AppName + " board attach serial:///dev/tty/ACM0 mySketch",
" " + global.GetAppName() + " board attach serial:///dev/tty/ACM0 mySketch",
}
boardCommand.AddCommand(initAttachCommand())
boardCommand.AddCommand(initDetailsCommand())
Expand Down
3 changes: 2 additions & 1 deletion cli/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/spf13/cobra"
Expand All @@ -35,7 +36,7 @@ func initDetailsCommand() *cobra.Command {
Use: "details <FQBN>",
Short: "Print details about a board.",
Long: "Show information about a board, in particular if the board has options to be specified in the FQBN.",
Example: " " + cli.AppName + " board details arduino:avr:nano",
Example: " " + global.GetAppName() + " board details arduino:avr:nano",
Args: cobra.ExactArgs(1),
Run: runDetailsCommand,
}
Expand Down
3 changes: 2 additions & 1 deletion cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/spf13/cobra"
Expand All @@ -37,7 +38,7 @@ func initListCommand() *cobra.Command {
Use: "list",
Short: "List connected boards.",
Long: "Detects and displays a list of connected boards to the current computer.",
Example: " " + cli.AppName + " board list --timeout 10s",
Example: " " + global.GetAppName() + " board list --timeout 10s",
Args: cobra.NoArgs,
Run: runListCommand,
}
Expand Down
5 changes: 3 additions & 2 deletions cli/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/spf13/cobra"
Expand All @@ -39,8 +40,8 @@ func initListAllCommand() *cobra.Command {
"List all boards that have the support platform installed. You can search\n" +
"for a specific board if you specify the board name",
Example: "" +
" " + cli.AppName + " board listall\n" +
" " + cli.AppName + " board listall zero",
" " + global.GetAppName() + " board listall\n" +
" " + global.GetAppName() + " board listall zero",
Args: cobra.ArbitraryArgs,
Run: runListAllCommand,
}
Expand Down
9 changes: 3 additions & 6 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
"context"
"errors"
"os"
"path/filepath"

"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/configs"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
paths "github.com/arduino/go-paths-helper"
"github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -61,9 +61,6 @@ var GlobalFlags struct {
OutputJSON bool // true output in JSON, false output as Text
}

// AppName is the command line name of the Arduino CLI executable
var AppName = filepath.Base(os.Args[0])

var Config *configs.Configuration

func packageManagerInitReq() *rpc.InitReq {
Expand Down Expand Up @@ -116,7 +113,7 @@ func CreateInstance() *rpc.Instance {
for _, err := range resp.GetPlatformsIndexErrors() {
formatter.PrintError(errors.New(err), "Error loading index")
}
formatter.PrintErrorMessage("Launch '" + AppName + " core update-index' to fix or download indexes.")
formatter.PrintErrorMessage("Launch '" + global.GetAppName() + " core update-index' to fix or download indexes.")
os.Exit(ErrGeneric)
}
return resp.GetInstance()
Expand Down
3 changes: 2 additions & 1 deletion cli/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/compile"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/arduino/go-paths-helper"
"github.com/spf13/cobra"
Expand All @@ -35,7 +36,7 @@ func InitCommand() *cobra.Command {
Use: "compile",
Short: "Compiles Arduino sketches.",
Long: "Compiles Arduino sketches.",
Example: " " + cli.AppName + " compile -b arduino:avr:uno /home/user/Arduino/MySketch",
Example: " " + global.GetAppName() + " compile -b arduino:avr:uno /home/user/Arduino/MySketch",
Args: cobra.MaximumNArgs(1),
Run: run,
}
Expand Down
4 changes: 2 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package config

import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/global"
"github.com/spf13/cobra"
)

Expand All @@ -27,7 +27,7 @@ func InitCommand() *cobra.Command {
configCommand := &cobra.Command{
Use: "config",
Short: "Arduino Configuration Commands.",
Example: " " + cli.AppName + " config init",
Example: " " + global.GetAppName() + " config init",
}
configCommand.AddCommand(initDumpCommand())
configCommand.AddCommand(initInitCommand())
Expand Down
3 changes: 2 additions & 1 deletion cli/config/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -32,7 +33,7 @@ func initDumpCommand() *cobra.Command {
Use: "dump",
Short: "Prints the current configuration",
Long: "Prints the current configuration.",
Example: " " + cli.AppName + " config dump",
Example: " " + global.GetAppName() + " config dump",
Args: cobra.NoArgs,
Run: runDumpCommand,
}
Expand Down
5 changes: 3 additions & 2 deletions cli/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -33,9 +34,9 @@ func initInitCommand() *cobra.Command {
Long: "Initializes a new config file into the default location ($EXE_DIR/cli-config.yml).",
Example: "" +
" # Creates a config file by asking questions to the user into the default location.\n" +
" " + cli.AppName + " config init\n\n" +
" " + global.GetAppName() + " config init\n\n" +
" # Creates a config file with default configuration into default location.\n" +
" " + cli.AppName + " config init --default\n",
" " + global.GetAppName() + " config init --default\n",
Args: cobra.NoArgs,
Run: runInitCommand,
}
Expand Down
4 changes: 2 additions & 2 deletions cli/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package core

import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/global"
"github.com/spf13/cobra"
)

Expand All @@ -28,7 +28,7 @@ func InitCommand() *cobra.Command {
Use: "core",
Short: "Arduino Core operations.",
Long: "Arduino Core operations.",
Example: " " + cli.AppName + " core update-index",
Example: " " + global.GetAppName() + " core update-index",
}
coreCommand.AddCommand(initDownloadCommand())
coreCommand.AddCommand(initInstallCommand())
Expand Down
5 changes: 3 additions & 2 deletions cli/core/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -35,8 +36,8 @@ func initDownloadCommand() *cobra.Command {
Short: "Downloads one or more cores and corresponding tool dependencies.",
Long: "Downloads one or more cores and corresponding tool dependencies.",
Example: "" +
" " + cli.AppName + " core download arduino:samd # to download the latest version of arduino SAMD core.\n" +
" " + cli.AppName + " core download arduino:samd=1.6.9 # for a specific version (in this case 1.6.9).",
" " + global.GetAppName() + " core download arduino:samd # to download the latest version of arduino SAMD core.\n" +
" " + global.GetAppName() + " core download arduino:samd=1.6.9 # for a specific version (in this case 1.6.9).",
Args: cobra.MinimumNArgs(1),
Run: runDownloadCommand,
}
Expand Down
5 changes: 3 additions & 2 deletions cli/core/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -35,9 +36,9 @@ func initInstallCommand() *cobra.Command {
Short: "Installs one or more cores and corresponding tool dependencies.",
Long: "Installs one or more cores and corresponding tool dependencies.",
Example: " # download the latest version of arduino SAMD core.\n" +
" " + cli.AppName + " core install arduino:samd\n\n" +
" " + global.GetAppName() + " core install arduino:samd\n\n" +
" # download a specific version (in this case 1.6.9).\n" +
" " + cli.AppName + " core install arduino:samd@1.6.9",
" " + global.GetAppName() + " core install arduino:samd@1.6.9",
Args: cobra.MinimumNArgs(1),
Run: runInstallCommand,
}
Expand Down
3 changes: 2 additions & 1 deletion cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
Expand All @@ -37,7 +38,7 @@ func initListCommand() *cobra.Command {
Use: "list",
Short: "Shows the list of installed platforms.",
Long: "Shows the list of installed platforms.",
Example: " " + cli.AppName + " core list",
Example: " " + global.GetAppName() + " core list",
Args: cobra.NoArgs,
Run: runListCommand,
}
Expand Down
3 changes: 2 additions & 1 deletion cli/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
Expand All @@ -38,7 +39,7 @@ func initSearchCommand() *cobra.Command {
Use: "search <keywords...>",
Short: "Search for a core in the package index.",
Long: "Search for a core in the package index using the specified keywords.",
Example: " " + cli.AppName + " core search MKRZero -v",
Example: " " + global.GetAppName() + " core search MKRZero -v",
Args: cobra.MinimumNArgs(1),
Run: runSearchCommand,
}
Expand Down
3 changes: 2 additions & 1 deletion cli/core/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/output"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
Expand All @@ -35,7 +36,7 @@ func initUninstallCommand() *cobra.Command {
Use: "uninstall PACKAGER:ARCH ...",
Short: "Uninstalls one or more cores and corresponding tool dependencies if no more used.",
Long: "Uninstalls one or more cores and corresponding tool dependencies if no more used.",
Example: " " + cli.AppName + " core uninstall arduino:samd\n",
Example: " " + global.GetAppName() + " core uninstall arduino:samd\n",
Args: cobra.MinimumNArgs(1),
Run: runUninstallCommand,
}
Expand Down
3 changes: 2 additions & 1 deletion cli/core/update_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -34,7 +35,7 @@ func initUpdateIndexCommand() *cobra.Command {
Use: "update-index",
Short: "Updates the index of cores.",
Long: "Updates the index of cores to the latest version.",
Example: " " + cli.AppName + " core update-index",
Example: " " + global.GetAppName() + " core update-index",
Args: cobra.NoArgs,
Run: runUpdateIndexCommand,
}
Expand Down
5 changes: 3 additions & 2 deletions cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -36,9 +37,9 @@ func initUpgradeCommand() *cobra.Command {
Long: "Upgrades one or all installed platforms to the latest version.",
Example: "" +
" # upgrade everything to the latest version\n" +
" " + cli.AppName + " core upgrade\n\n" +
" " + global.GetAppName() + " core upgrade\n\n" +
" # upgrade arduino:samd to the latest version\n" +
" " + cli.AppName + " core upgrade arduino:samd",
" " + global.GetAppName() + " core upgrade arduino:samd",
Run: runUpgradeCommand,
}
return upgradeCommand
Expand Down
4 changes: 2 additions & 2 deletions cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"log"
"net"

"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/daemon"
"github.com/arduino/arduino-cli/global"
"github.com/arduino/arduino-cli/rpc"
"github.com/spf13/cobra"
"google.golang.org/grpc"
Expand All @@ -35,7 +35,7 @@ func InitCommand() *cobra.Command {
Use: "daemon",
Short: "Run as a daemon",
Long: "Running as a daemon the initialization of cores and libraries is done only once.",
Example: " " + cli.AppName + " daemon",
Example: " " + global.GetAppName() + " daemon",
Args: cobra.NoArgs,
Run: runDaemonCommand,
Hidden: true,
Expand Down
3 changes: 2 additions & 1 deletion cli/generatedocs/generatedocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"

"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/global"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
Expand All @@ -33,7 +34,7 @@ func InitCommand() *cobra.Command {
Use: "generate-docs",
Short: "Generates bash completion and command manpages.",
Long: "Generates bash completion and command manpages.",
Example: " " + cli.AppName + " generate-docs bash-completions",
Example: " " + global.GetAppName() + " generate-docs bash-completions",
}
command.PersistentFlags().StringVarP(&outputDir, "output-dir", "o", "",
"Directory where to save generated files. Default is './docs', the directory must exist.")
Expand Down
Loading