Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
8ff498b6
Commit
8ff498b6
authored
Nov 09, 2021
by
Umberto Baldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
general improvements for consistency between commands
parent
aeb15287
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
50 additions
and
48 deletions
+50
-48
cli/burnbootloader/burnbootloader.go
cli/burnbootloader/burnbootloader.go
+2
-2
cli/compile/compile.go
cli/compile/compile.go
+2
-2
cli/completion/completion.go
cli/completion/completion.go
+5
-5
cli/config/config.go
cli/config/config.go
+1
-1
cli/config/delete.go
cli/config/delete.go
+2
-2
cli/config/dump.go
cli/config/dump.go
+8
-8
cli/config/remove.go
cli/config/remove.go
+2
-2
cli/config/set.go
cli/config/set.go
+2
-2
cli/core/uninstall.go
cli/core/uninstall.go
+2
-1
cli/daemon/daemon.go
cli/daemon/daemon.go
+7
-7
cli/generatedocs/generatedocs.go
cli/generatedocs/generatedocs.go
+6
-6
cli/sketch/archive.go
cli/sketch/archive.go
+3
-3
cli/sketch/sketch.go
cli/sketch/sketch.go
+4
-4
cli/version/version.go
cli/version/version.go
+4
-3
No files found.
cli/burnbootloader/burnbootloader.go
View file @
8ff498b6
...
...
@@ -47,7 +47,7 @@ func NewCommand() *cobra.Command {
Long
:
tr
(
"Upload the bootloader on the board using an external programmer."
),
Example
:
" "
+
os
.
Args
[
0
]
+
" burn-bootloader -b arduino:avr:uno -P atmel_ice"
,
Args
:
cobra
.
MaximumNArgs
(
1
),
Run
:
run
,
Run
:
run
BootloaderCommand
,
}
fqbn
.
AddToCommand
(
burnBootloaderCommand
)
...
...
@@ -61,7 +61,7 @@ func NewCommand() *cobra.Command {
return
burnBootloaderCommand
}
func
run
(
command
*
cobra
.
Command
,
args
[]
string
)
{
func
run
BootloaderCommand
(
command
*
cobra
.
Command
,
args
[]
string
)
{
instance
:=
instance
.
CreateAndInit
()
// We don't need a Sketch to upload a board's bootloader
...
...
cli/compile/compile.go
View file @
8ff498b6
...
...
@@ -76,7 +76,7 @@ func NewCommand() *cobra.Command {
" "
+
os
.
Args
[
0
]
+
` compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch`
+
"
\n
"
+
" "
+
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
"
,
Args
:
cobra
.
MaximumNArgs
(
1
),
Run
:
run
,
Run
:
run
CompileCommand
,
}
fqbn
.
AddToCommand
(
compileCommand
)
...
...
@@ -120,7 +120,7 @@ func NewCommand() *cobra.Command {
return
compileCommand
}
func
run
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
run
CompileCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
inst
:=
instance
.
CreateAndInit
()
path
:=
""
...
...
cli/completion/completion.go
View file @
8ff498b6
...
...
@@ -31,7 +31,7 @@ var (
// NewCommand created a new `completion` command
func
NewCommand
()
*
cobra
.
Command
{
command
:=
&
cobra
.
Command
{
com
pletionCom
mand
:=
&
cobra
.
Command
{
Use
:
"completion [bash|zsh|fish|powershell] [--no-descriptions]"
,
ValidArgs
:
[]
string
{
"bash"
,
"zsh"
,
"fish"
,
"powershell"
},
Args
:
cobra
.
ExactArgs
(
1
),
...
...
@@ -39,14 +39,14 @@ func NewCommand() *cobra.Command {
Long
:
tr
(
"Generates completion scripts for various shells"
),
Example
:
" "
+
os
.
Args
[
0
]
+
" completion bash > completion.sh
\n
"
+
" "
+
"source completion.sh"
,
Run
:
run
,
Run
:
run
CompletionCommand
,
}
command
.
Flags
()
.
BoolVar
(
&
completionNoDesc
,
"no-descriptions"
,
false
,
tr
(
"Disable completion description for shells that support it"
))
com
pletionCom
mand
.
Flags
()
.
BoolVar
(
&
completionNoDesc
,
"no-descriptions"
,
false
,
tr
(
"Disable completion description for shells that support it"
))
return
command
return
com
pletionCom
mand
}
func
run
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
run
CompletionCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
completionNoDesc
&&
(
args
[
0
]
==
"powershell"
)
{
feedback
.
Errorf
(
tr
(
"Error: command description is not supported by %v"
),
args
[
0
])
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
cli/config/config.go
View file @
8ff498b6
...
...
@@ -36,7 +36,7 @@ func NewCommand() *cobra.Command {
configCommand
.
AddCommand
(
initAddCommand
())
configCommand
.
AddCommand
(
initDeleteCommand
())
configCommand
.
AddCommand
(
initDumpC
m
d
())
configCommand
.
AddCommand
(
initDumpC
omman
d
())
configCommand
.
AddCommand
(
initInitCommand
())
configCommand
.
AddCommand
(
initRemoveCommand
())
configCommand
.
AddCommand
(
initSetCommand
())
...
...
cli/config/delete.go
View file @
8ff498b6
...
...
@@ -27,7 +27,7 @@ import (
)
func
initDeleteCommand
()
*
cobra
.
Command
{
add
Command
:=
&
cobra
.
Command
{
delete
Command
:=
&
cobra
.
Command
{
Use
:
"delete"
,
Short
:
tr
(
"Deletes a settings key and all its sub keys."
),
Long
:
tr
(
"Deletes a settings key and all its sub keys."
),
...
...
@@ -40,7 +40,7 @@ func initDeleteCommand() *cobra.Command {
return
configuration
.
Settings
.
AllKeys
(),
cobra
.
ShellCompDirectiveDefault
},
}
return
add
Command
return
delete
Command
}
func
runDeleteCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/config/dump.go
View file @
8ff498b6
...
...
@@ -25,8 +25,8 @@ import (
"gopkg.in/yaml.v2"
)
func
initDumpC
m
d
()
*
cobra
.
Command
{
var
dumpC
m
d
=
&
cobra
.
Command
{
func
initDumpC
omman
d
()
*
cobra
.
Command
{
var
dumpC
omman
d
=
&
cobra
.
Command
{
Use
:
"dump"
,
Short
:
tr
(
"Prints the current configuration"
),
Long
:
tr
(
"Prints the current configuration."
),
...
...
@@ -34,7 +34,12 @@ func initDumpCmd() *cobra.Command {
Args
:
cobra
.
NoArgs
,
Run
:
runDumpCommand
,
}
return
dumpCmd
return
dumpCommand
}
func
runDumpCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
logrus
.
Info
(
"Executing `arduino config dump`"
)
feedback
.
PrintResult
(
dumpResult
{
configuration
.
Settings
.
AllSettings
()})
}
// output from this command requires special formatting, let's create a dedicated
...
...
@@ -56,8 +61,3 @@ func (dr dumpResult) String() string {
return
string
(
bs
)
}
func
runDumpCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
logrus
.
Info
(
"Executing `arduino config dump`"
)
feedback
.
PrintResult
(
dumpResult
{
configuration
.
Settings
.
AllSettings
()})
}
cli/config/remove.go
View file @
8ff498b6
...
...
@@ -26,7 +26,7 @@ import (
)
func
initRemoveCommand
()
*
cobra
.
Command
{
add
Command
:=
&
cobra
.
Command
{
remove
Command
:=
&
cobra
.
Command
{
Use
:
"remove"
,
Short
:
tr
(
"Removes one or more values from a setting."
),
Long
:
tr
(
"Removes one or more values from a setting."
),
...
...
@@ -39,7 +39,7 @@ func initRemoveCommand() *cobra.Command {
return
GetConfigurationKeys
(),
cobra
.
ShellCompDirectiveDefault
},
}
return
add
Command
return
remove
Command
}
func
runRemoveCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/config/set.go
View file @
8ff498b6
...
...
@@ -27,7 +27,7 @@ import (
)
func
initSetCommand
()
*
cobra
.
Command
{
add
Command
:=
&
cobra
.
Command
{
set
Command
:=
&
cobra
.
Command
{
Use
:
"set"
,
Short
:
tr
(
"Sets a setting value."
),
Long
:
tr
(
"Sets a setting value."
),
...
...
@@ -42,7 +42,7 @@ func initSetCommand() *cobra.Command {
return
configuration
.
Settings
.
AllKeys
(),
cobra
.
ShellCompDirectiveDefault
},
}
return
add
Command
return
set
Command
}
func
runSetCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/core/uninstall.go
View file @
8ff498b6
...
...
@@ -32,7 +32,7 @@ import (
)
func
initUninstallCommand
()
*
cobra
.
Command
{
return
&
cobra
.
Command
{
uninstallCommand
:=
&
cobra
.
Command
{
Use
:
fmt
.
Sprintf
(
"uninstall %s:%s ..."
,
tr
(
"PACKAGER"
),
tr
(
"ARCH"
)),
Short
:
tr
(
"Uninstalls one or more cores and corresponding tool dependencies if no longer used."
),
Long
:
tr
(
"Uninstalls one or more cores and corresponding tool dependencies if no longer used."
),
...
...
@@ -43,6 +43,7 @@ func initUninstallCommand() *cobra.Command {
return
arguments
.
GetUninstallableCores
(),
cobra
.
ShellCompDirectiveDefault
},
}
return
uninstallCommand
}
func
runUninstallCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/daemon/daemon.go
View file @
8ff498b6
...
...
@@ -50,7 +50,7 @@ var (
// NewCommand created a new `daemon` command
func
NewCommand
()
*
cobra
.
Command
{
cm
d
:=
&
cobra
.
Command
{
daemonComman
d
:=
&
cobra
.
Command
{
Use
:
"daemon"
,
Short
:
tr
(
"Run as a daemon on port: %s"
,
configuration
.
Settings
.
GetString
(
"daemon.port"
)),
Long
:
tr
(
"Running as a daemon the initialization of cores and libraries is done only once."
),
...
...
@@ -58,12 +58,12 @@ func NewCommand() *cobra.Command {
Args
:
cobra
.
NoArgs
,
Run
:
runDaemonCommand
,
}
cm
d
.
PersistentFlags
()
.
String
(
"port"
,
""
,
tr
(
"The TCP port the daemon will listen to"
))
configuration
.
Settings
.
BindPFlag
(
"daemon.port"
,
cm
d
.
PersistentFlags
()
.
Lookup
(
"port"
))
cm
d
.
Flags
()
.
BoolVar
(
&
daemonize
,
"daemonize"
,
false
,
tr
(
"Do not terminate daemon process if the parent process dies"
))
cm
d
.
Flags
()
.
BoolVar
(
&
debug
,
"debug"
,
false
,
tr
(
"Enable debug logging of gRPC calls"
))
cm
d
.
Flags
()
.
StringSliceVar
(
&
debugFilters
,
"debug-filter"
,
[]
string
{},
tr
(
"Display only the provided gRPC calls"
))
return
cm
d
daemonComman
d
.
PersistentFlags
()
.
String
(
"port"
,
""
,
tr
(
"The TCP port the daemon will listen to"
))
configuration
.
Settings
.
BindPFlag
(
"daemon.port"
,
daemonComman
d
.
PersistentFlags
()
.
Lookup
(
"port"
))
daemonComman
d
.
Flags
()
.
BoolVar
(
&
daemonize
,
"daemonize"
,
false
,
tr
(
"Do not terminate daemon process if the parent process dies"
))
daemonComman
d
.
Flags
()
.
BoolVar
(
&
debug
,
"debug"
,
false
,
tr
(
"Enable debug logging of gRPC calls"
))
daemonComman
d
.
Flags
()
.
StringSliceVar
(
&
debugFilters
,
"debug-filter"
,
[]
string
{},
tr
(
"Display only the provided gRPC calls"
))
return
daemonComman
d
}
func
runDaemonCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/generatedocs/generatedocs.go
View file @
8ff498b6
...
...
@@ -31,9 +31,9 @@ var (
tr
=
i18n
.
Tr
)
// NewCommand created a new `generatedocs` command
// NewCommand created a new `generate
-
docs` command
func
NewCommand
()
*
cobra
.
Command
{
c
ommand
:=
&
cobra
.
Command
{
generateDocsC
ommand
:=
&
cobra
.
Command
{
Use
:
"generate-docs"
,
Short
:
tr
(
"Generates bash completion and command manpages."
),
Long
:
tr
(
"Generates bash completion and command manpages."
),
...
...
@@ -41,20 +41,20 @@ func NewCommand() *cobra.Command {
Hidden
:
true
,
}
c
ommand
.
PersistentFlags
()
.
StringVarP
(
&
outputDir
,
"output-dir"
,
"o"
,
""
,
generateDocsC
ommand
.
PersistentFlags
()
.
StringVarP
(
&
outputDir
,
"output-dir"
,
"o"
,
""
,
tr
(
"Directory where to save generated files. Default is './docs', the directory must exist."
))
c
ommand
.
AddCommand
(
&
cobra
.
Command
{
generateDocsC
ommand
.
AddCommand
(
&
cobra
.
Command
{
Use
:
"manpage"
,
Args
:
cobra
.
NoArgs
,
Run
:
generateManPages
,
})
c
ommand
.
AddCommand
(
&
cobra
.
Command
{
generateDocsC
ommand
.
AddCommand
(
&
cobra
.
Command
{
Use
:
"bash-completions"
,
Args
:
cobra
.
NoArgs
,
Run
:
generateBashCompletions
,
})
return
c
ommand
return
generateDocsC
ommand
}
func
generateBashCompletions
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/sketch/archive.go
View file @
8ff498b6
...
...
@@ -34,7 +34,7 @@ var includeBuildDir bool
// initArchiveCommand creates a new `archive` command
func
initArchiveCommand
()
*
cobra
.
Command
{
c
ommand
:=
&
cobra
.
Command
{
archiveC
ommand
:=
&
cobra
.
Command
{
Use
:
fmt
.
Sprintf
(
"archive <%s> <%s>"
,
tr
(
"sketchPath"
),
tr
(
"archivePath"
)),
Short
:
tr
(
"Creates a zip file containing all sketch files."
),
Long
:
tr
(
"Creates a zip file containing all sketch files."
),
...
...
@@ -48,9 +48,9 @@ func initArchiveCommand() *cobra.Command {
Run
:
runArchiveCommand
,
}
c
ommand
.
Flags
()
.
BoolVar
(
&
includeBuildDir
,
"include-build-dir"
,
false
,
tr
(
"Includes %s directory in the archive."
,
"build"
))
archiveC
ommand
.
Flags
()
.
BoolVar
(
&
includeBuildDir
,
"include-build-dir"
,
false
,
tr
(
"Includes %s directory in the archive."
,
"build"
))
return
c
ommand
return
archiveC
ommand
}
func
runArchiveCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
cli/sketch/sketch.go
View file @
8ff498b6
...
...
@@ -26,15 +26,15 @@ var tr = i18n.Tr
// NewCommand created a new `sketch` command
func
NewCommand
()
*
cobra
.
Command
{
cm
d
:=
&
cobra
.
Command
{
sketchComman
d
:=
&
cobra
.
Command
{
Use
:
"sketch"
,
Short
:
tr
(
"Arduino CLI sketch commands."
),
Long
:
tr
(
"Arduino CLI sketch commands."
),
Example
:
" "
+
os
.
Args
[
0
]
+
" sketch new MySketch"
,
}
cm
d
.
AddCommand
(
initNewCommand
())
cm
d
.
AddCommand
(
initArchiveCommand
())
sketchComman
d
.
AddCommand
(
initNewCommand
())
sketchComman
d
.
AddCommand
(
initArchiveCommand
())
return
cm
d
return
sketchComman
d
}
cli/version/version.go
View file @
8ff498b6
...
...
@@ -32,17 +32,18 @@ var tr = i18n.Tr
// NewCommand created a new `version` command
func
NewCommand
()
*
cobra
.
Command
{
return
&
cobra
.
Command
{
versionCommand
:=
&
cobra
.
Command
{
Use
:
"version"
,
Short
:
tr
(
"Shows version number of Arduino CLI."
),
Long
:
tr
(
"Shows the version number of Arduino CLI which is installed on your system."
),
Example
:
" "
+
os
.
Args
[
0
]
+
" version"
,
Args
:
cobra
.
NoArgs
,
Run
:
run
,
Run
:
run
VersionCommand
,
}
return
versionCommand
}
func
run
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
run
VersionCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
strings
.
Contains
(
globals
.
VersionInfo
.
VersionString
,
"git-snapshot"
)
||
strings
.
Contains
(
globals
.
VersionInfo
.
VersionString
,
"nightly"
)
{
// We're using a development version, no need to check if there's a
// new release available
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment