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
aeb15287
Commit
aeb15287
authored
Nov 18, 2021
by
Umberto Baldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor monitor command to be consistent with other commands
parent
0f259643
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
cli/monitor/monitor.go
cli/monitor/monitor.go
+18
-20
No files found.
cli/monitor/monitor.go
View file @
aeb15287
...
...
@@ -37,17 +37,18 @@ import (
"github.com/spf13/cobra"
)
var
tr
=
i18n
.
Tr
var
portArgs
arguments
.
Port
var
describe
bool
var
configs
[]
string
var
quiet
bool
var
fqbn
string
var
(
portArgs
arguments
.
Port
describe
bool
configs
[]
string
quiet
bool
fqbn
arguments
.
Fqbn
tr
=
i18n
.
Tr
)
// NewCommand created a new `monitor` command
func
NewCommand
()
*
cobra
.
Command
{
cm
d
:=
&
cobra
.
Command
{
monitorComman
d
:=
&
cobra
.
Command
{
Use
:
"monitor"
,
Short
:
tr
(
"Open a communication port with a board."
),
Long
:
tr
(
"Open a communication port with a board."
),
...
...
@@ -56,16 +57,13 @@ func NewCommand() *cobra.Command {
" "
+
os
.
Args
[
0
]
+
" monitor -p /dev/ttyACM0 --describe"
,
Run
:
runMonitorCmd
,
}
portArgs
.
AddToCommand
(
cmd
)
cmd
.
Flags
()
.
BoolVar
(
&
describe
,
"describe"
,
false
,
tr
(
"Show all the settings of the communication port."
))
cmd
.
Flags
()
.
StringSliceVarP
(
&
configs
,
"config"
,
"c"
,
[]
string
{},
tr
(
"Configuration of the port."
))
cmd
.
Flags
()
.
BoolVarP
(
&
quiet
,
"quiet"
,
"q"
,
false
,
tr
(
"Run in silent mode, show only monitor input and output."
))
cmd
.
Flags
()
.
StringVarP
(
&
fqbn
,
"fqbn"
,
"b"
,
""
,
tr
(
"Fully Qualified Board Name, e.g.: arduino:avr:uno"
))
cmd
.
RegisterFlagCompletionFunc
(
"fqbn"
,
func
(
cmd
*
cobra
.
Command
,
args
[]
string
,
toComplete
string
)
([]
string
,
cobra
.
ShellCompDirective
)
{
return
arguments
.
GetInstalledBoards
(),
cobra
.
ShellCompDirectiveDefault
})
cmd
.
MarkFlagRequired
(
"port"
)
return
cmd
portArgs
.
AddToCommand
(
monitorCommand
)
monitorCommand
.
Flags
()
.
BoolVar
(
&
describe
,
"describe"
,
false
,
tr
(
"Show all the settings of the communication port."
))
monitorCommand
.
Flags
()
.
StringSliceVarP
(
&
configs
,
"config"
,
"c"
,
[]
string
{},
tr
(
"Configuration of the port."
))
monitorCommand
.
Flags
()
.
BoolVarP
(
&
quiet
,
"quiet"
,
"q"
,
false
,
tr
(
"Run in silent mode, show only monitor input and output."
))
fqbn
.
AddToCommand
(
monitorCommand
)
monitorCommand
.
MarkFlagRequired
(
"port"
)
return
monitorCommand
}
func
runMonitorCmd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
@@ -84,7 +82,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
enumerateResp
,
err
:=
monitor
.
EnumerateMonitorPortSettings
(
context
.
Background
(),
&
rpc
.
EnumerateMonitorPortSettingsRequest
{
Instance
:
instance
,
PortProtocol
:
portProtocol
,
Fqbn
:
fqbn
,
Fqbn
:
fqbn
.
String
()
,
})
if
err
!=
nil
{
feedback
.
Error
(
tr
(
"Error getting port settings details: %s"
,
err
))
...
...
@@ -148,7 +146,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
portProxy
,
_
,
err
:=
monitor
.
Monitor
(
context
.
Background
(),
&
rpc
.
MonitorRequest
{
Instance
:
instance
,
Port
:
&
rpc
.
Port
{
Address
:
portAddress
,
Protocol
:
portProtocol
},
Fqbn
:
fqbn
,
Fqbn
:
fqbn
.
String
()
,
PortConfiguration
:
configuration
,
})
if
err
!=
nil
{
...
...
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