Skip to content

Commit 34b629a

Browse files
committed
Applied review suggestions
* rename --silent to --quiet * removed useless 'settings' variable * translation string for "Monitor port settings" in CLI mode
1 parent 21f55b9 commit 34b629a

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

Diff for: cli/monitor/monitor.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var tr = i18n.Tr
4242
var portArgs arguments.Port
4343
var describe bool
4444
var configs []string
45-
var silent bool
45+
var quiet bool
4646

4747
// NewCommand created a new `monitor` command
4848
func NewCommand() *cobra.Command {
@@ -58,7 +58,7 @@ func NewCommand() *cobra.Command {
5858
portArgs.AddToCommand(cmd)
5959
cmd.Flags().BoolVar(&describe, "describe", false, tr("Show all the settings of the communication port."))
6060
cmd.Flags().StringSliceVarP(&configs, "config", "c", []string{}, tr("Configuration of the port."))
61-
cmd.Flags().BoolVarP(&silent, "silent", "s", false, tr("Run in silent mode, show only monitor input and output."))
61+
cmd.Flags().BoolVarP(&quiet, "quiet", "q", false, tr("Run in silent mode, show only monitor input and output."))
6262
cmd.MarkFlagRequired("port")
6363
return cmd
6464
}
@@ -67,7 +67,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
6767
instance := instance.CreateAndInit()
6868

6969
if !configuration.HasConsole {
70-
silent = true
70+
quiet = true
7171
}
7272

7373
port, err := portArgs.GetPort(instance, nil)
@@ -108,7 +108,6 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
108108
feedback.Error(err)
109109
os.Exit(errorcodes.ErrGeneric)
110110
}
111-
settings := resp.GetSettings()
112111
for _, config := range configs {
113112
split := strings.SplitN(config, "=", 2)
114113
k := ""
@@ -119,7 +118,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
119118
}
120119

121120
var setting *rpc.MonitorPortSettingDescriptor
122-
for _, s := range settings {
121+
for _, s := range resp.GetSettings() {
123122
if k == "" {
124123
if contains(s.EnumValues, v) {
125124
setting = s
@@ -144,8 +143,9 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
144143
SettingId: setting.SettingId,
145144
Value: v,
146145
})
147-
if !silent {
148-
feedback.Print(fmt.Sprintf("Set %s to %s", setting.SettingId, v))
146+
if !quiet {
147+
feedback.Print(tr("Monitor port settings:"))
148+
feedback.Print(fmt.Sprintf("%s=%s", setting.SettingId, v))
149149
}
150150
}
151151
}
@@ -177,7 +177,7 @@ func runMonitorCmd(cmd *cobra.Command, args []string) {
177177
cancel()
178178
}()
179179

180-
if !silent {
180+
if !quiet {
181181
feedback.Print(tr("Connected to %s! Press CTRL-C to exit.", port.String()))
182182
}
183183

Diff for: i18n/data/en.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,10 @@ msgstr "Missing sketch path"
14751475
msgid "Monitor '%s' not found"
14761476
msgstr "Monitor '%s' not found"
14771477

1478+
#: cli/monitor/monitor.go:147
1479+
msgid "Monitor port settings:"
1480+
msgstr "Monitor port settings:"
1481+
14781482
#: legacy/builder/print_used_and_not_used_libraries.go:50
14791483
msgid "Multiple libraries were found for \"{0}\""
14801484
msgstr "Multiple libraries were found for \"{0}\""
@@ -2851,11 +2855,11 @@ msgstr "invalid platform archive size: %s"
28512855
msgid "invalid pluggable monitor reference: %s"
28522856
msgstr "invalid pluggable monitor reference: %s"
28532857

2854-
#: cli/monitor/monitor.go:131
2858+
#: cli/monitor/monitor.go:130
28552859
msgid "invalid port configuration value for %s: %s"
28562860
msgstr "invalid port configuration value for %s: %s"
28572861

2858-
#: cli/monitor/monitor.go:140
2862+
#: cli/monitor/monitor.go:139
28592863
msgid "invalid port configuration: %s"
28602864
msgstr "invalid port configuration: %s"
28612865

Diff for: i18n/rice-box.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)