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
1a94fdff
Commit
1a94fdff
authored
Nov 19, 2021
by
Umberto Baldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uniform the usage of vars in board sub-commands
parent
e72f6839
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
28 deletions
+25
-28
cli/board/attach.go
cli/board/attach.go
+4
-6
cli/board/board.go
cli/board/board.go
+3
-0
cli/board/details.go
cli/board/details.go
+5
-5
cli/board/list.go
cli/board/list.go
+9
-9
cli/board/listall.go
cli/board/listall.go
+2
-2
cli/board/search.go
cli/board/search.go
+2
-6
No files found.
cli/board/attach.go
View file @
1a94fdff
...
...
@@ -30,6 +30,8 @@ import (
"github.com/spf13/cobra"
)
var
searchTimeout
string
// Expressed in a parsable duration, is the timeout for the list and attach commands.
func
initAttachCommand
()
*
cobra
.
Command
{
attachCommand
:=
&
cobra
.
Command
{
Use
:
fmt
.
Sprintf
(
"attach <%s>|<%s> [%s]"
,
tr
(
"port"
),
tr
(
"FQBN"
),
tr
(
"sketchPath"
)),
...
...
@@ -41,15 +43,11 @@ func initAttachCommand() *cobra.Command {
Args
:
cobra
.
RangeArgs
(
1
,
2
),
Run
:
runAttachCommand
,
}
attachCommand
.
Flags
()
.
StringVar
(
&
attachFlags
.
searchTimeout
,
"timeout"
,
"5s"
,
attachCommand
.
Flags
()
.
StringVar
(
&
searchTimeout
,
"timeout"
,
"5s"
,
tr
(
"The connected devices search timeout, raise it if your board doesn't show up (e.g. to %s)."
,
"10s"
))
return
attachCommand
}
var
attachFlags
struct
{
searchTimeout
string
// Expressed in a parsable duration, is the timeout for the list and attach commands.
}
func
runAttachCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
instance
:=
instance
.
CreateAndInit
()
...
...
@@ -63,7 +61,7 @@ func runAttachCommand(cmd *cobra.Command, args []string) {
Instance
:
instance
,
BoardUri
:
args
[
0
],
SketchPath
:
sketchPath
.
String
(),
SearchTimeout
:
attachFlags
.
searchTimeout
,
SearchTimeout
:
searchTimeout
,
},
output
.
TaskProgress
());
err
!=
nil
{
feedback
.
Errorf
(
tr
(
"Attach board error: %v"
),
err
)
os
.
Exit
(
errorcodes
.
ErrGeneric
)
...
...
cli/board/board.go
View file @
1a94fdff
...
...
@@ -18,9 +18,12 @@ package board
import
(
"os"
"github.com/arduino/arduino-cli/i18n"
"github.com/spf13/cobra"
)
var
tr
=
i18n
.
Tr
// NewCommand created a new `board` command
func
NewCommand
()
*
cobra
.
Command
{
boardCommand
:=
&
cobra
.
Command
{
...
...
cli/board/details.go
View file @
1a94fdff
...
...
@@ -25,17 +25,17 @@ import (
"github.com/arduino/arduino-cli/cli/feedback"
"github.com/arduino/arduino-cli/cli/instance"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/i18n"
rpc
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/arduino-cli/table"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
var
tr
=
i18n
.
Tr
var
showFullDetails
bool
var
fqbn
string
var
listProgrammers
bool
var
(
showFullDetails
bool
fqbn
string
listProgrammers
bool
)
func
initDetailsCommand
()
*
cobra
.
Command
{
var
detailsCommand
=
&
cobra
.
Command
{
...
...
cli/board/list.go
View file @
1a94fdff
...
...
@@ -31,6 +31,11 @@ import (
"github.com/spf13/cobra"
)
var
(
timeout
time
.
Duration
watch
bool
)
func
initListCommand
()
*
cobra
.
Command
{
listCommand
:=
&
cobra
.
Command
{
Use
:
"list"
,
...
...
@@ -41,22 +46,17 @@ func initListCommand() *cobra.Command {
Run
:
runListCommand
,
}
listCommand
.
Flags
()
.
DurationVar
(
&
listFlags
.
timeout
,
"timeout"
,
time
.
Second
,
listCommand
.
Flags
()
.
DurationVar
(
&
timeout
,
"timeout"
,
time
.
Second
,
tr
(
"The connected devices search timeout, raise it if your board doesn't show up e.g.: 10s"
))
listCommand
.
Flags
()
.
BoolVarP
(
&
listFlags
.
watch
,
"watch"
,
"w"
,
false
,
listCommand
.
Flags
()
.
BoolVarP
(
&
watch
,
"watch"
,
"w"
,
false
,
tr
(
"Command keeps running and prints list of connected boards whenever there is a change."
))
return
listCommand
}
var
listFlags
struct
{
timeout
time
.
Duration
watch
bool
}
// runListCommand detects and lists the connected arduino boards
func
runListCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
listFlags
.
watch
{
if
watch
{
inst
:=
instance
.
CreateAndInit
()
watchList
(
cmd
,
inst
)
os
.
Exit
(
0
)
...
...
@@ -65,7 +65,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
inst
:=
instance
.
CreateAndInit
()
ports
,
err
:=
board
.
List
(
&
rpc
.
BoardListRequest
{
Instance
:
inst
,
Timeout
:
listFlags
.
timeout
.
Milliseconds
(),
Timeout
:
timeout
.
Milliseconds
(),
})
if
err
!=
nil
{
feedback
.
Errorf
(
tr
(
"Error detecting boards: %v"
),
err
)
...
...
cli/board/listall.go
View file @
1a94fdff
...
...
@@ -30,6 +30,8 @@ import (
"github.com/spf13/cobra"
)
var
showHiddenBoard
bool
func
initListAllCommand
()
*
cobra
.
Command
{
var
listAllCommand
=
&
cobra
.
Command
{
Use
:
fmt
.
Sprintf
(
"listall [%s]"
,
tr
(
"boardname"
)),
...
...
@@ -46,8 +48,6 @@ for a specific board if you specify the board name`),
return
listAllCommand
}
var
showHiddenBoard
bool
// runListAllCommand list all installed boards
func
runListAllCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
inst
:=
instance
.
CreateAndInit
()
...
...
cli/board/search.go
View file @
1a94fdff
...
...
@@ -43,21 +43,17 @@ for a specific board if you specify the board name`),
Args
:
cobra
.
ArbitraryArgs
,
Run
:
runSearchCommand
,
}
searchCommand
.
Flags
()
.
BoolVarP
(
&
s
earchFlags
.
s
howHiddenBoard
,
"show-hidden"
,
"a"
,
false
,
tr
(
"Show also boards marked as 'hidden' in the platform"
))
searchCommand
.
Flags
()
.
BoolVarP
(
&
showHiddenBoard
,
"show-hidden"
,
"a"
,
false
,
tr
(
"Show also boards marked as 'hidden' in the platform"
))
return
searchCommand
}
var
searchFlags
struct
{
showHiddenBoard
bool
}
func
runSearchCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
inst
:=
instance
.
CreateAndInit
()
res
,
err
:=
board
.
Search
(
context
.
Background
(),
&
rpc
.
BoardSearchRequest
{
Instance
:
inst
,
SearchArgs
:
strings
.
Join
(
args
,
" "
),
IncludeHiddenBoards
:
s
earchFlags
.
s
howHiddenBoard
,
IncludeHiddenBoards
:
showHiddenBoard
,
})
if
err
!=
nil
{
feedback
.
Errorf
(
tr
(
"Error searching boards: %v"
),
err
)
...
...
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