Skip to content

Commit 28dfdc1

Browse files
committed
add completion for config add, config remove, config delete and config set
1 parent 3486d94 commit 28dfdc1

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

cli/config/add.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func initAddCommand() *cobra.Command {
3535
" " + os.Args[0] + " config add board_manager.additional_urls https://example.com/package_example_index.json https://another-url.com/package_another_index.json\n",
3636
Args: cobra.MinimumNArgs(2),
3737
Run: runAddCommand,
38+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
39+
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
40+
},
3841
}
3942
return addCommand
4043
}

cli/config/delete.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func initDeleteCommand() *cobra.Command {
3636
" " + os.Args[0] + " config delete board_manager.additional_urls",
3737
Args: cobra.ExactArgs(1),
3838
Run: runDeleteCommand,
39+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
40+
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
41+
},
3942
}
4043
return addCommand
4144
}

cli/config/remove.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func initRemoveCommand() *cobra.Command {
3535
" " + os.Args[0] + " config remove board_manager.additional_urls https://example.com/package_example_index.json https://another-url.com/package_another_index.json\n",
3636
Args: cobra.MinimumNArgs(2),
3737
Run: runRemoveCommand,
38+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
39+
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
40+
},
3841
}
3942
return addCommand
4043
}

cli/config/set.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func initSetCommand() *cobra.Command {
3838
" " + os.Args[0] + " config set board_manager.additional_urls https://example.com/package_example_index.json https://another-url.com/package_another_index.json",
3939
Args: cobra.MinimumNArgs(2),
4040
Run: runSetCommand,
41+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
42+
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
43+
},
4144
}
4245
return addCommand
4346
}

i18n/data/en.po

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,17 @@ msgstr "Can't find dependencies for platform %s"
264264
msgid "Can't open sketch"
265265
msgstr "Can't open sketch"
266266

267-
#: cli/config/set.go:54
267+
#: cli/config/set.go:57
268268
msgid "Can't set multiple values in key %v"
269269
msgstr "Can't set multiple values in key %v"
270270

271271
#: cli/config/init.go:59
272272
msgid "Can't use both --dest-file and --dest-dir flags at the same time."
273273
msgstr "Can't use both --dest-file and --dest-dir flags at the same time."
274274

275-
#: cli/config/add.go:60
276-
#: cli/config/delete.go:67
277-
#: cli/config/remove.go:69
275+
#: cli/config/add.go:63
276+
#: cli/config/delete.go:70
277+
#: cli/config/remove.go:72
278278
msgid "Can't write config file: %v"
279279
msgstr "Can't write config file: %v"
280280

@@ -1822,7 +1822,7 @@ msgstr "Sets a setting value."
18221822
msgid "Sets where to save the configuration file."
18231823
msgstr "Sets where to save the configuration file."
18241824

1825-
#: cli/config/delete.go:57
1825+
#: cli/config/delete.go:60
18261826
#: cli/config/validate.go:45
18271827
msgid "Settings key doesn't exist"
18281828
msgstr "Settings key doesn't exist"
@@ -1988,13 +1988,13 @@ msgstr "The custom config file (if not specified the default will be used)."
19881988
msgid "The flags --run-post-install and --skip-post-install can't be both set at the same time."
19891989
msgstr "The flags --run-post-install and --skip-post-install can't be both set at the same time."
19901990

1991-
#: cli/config/add.go:51
1991+
#: cli/config/add.go:54
19921992
msgid "The key '%[1]v' is not a list of items, can't add to it.\n"
19931993
"Maybe use '%[2]s'?"
19941994
msgstr "The key '%[1]v' is not a list of items, can't add to it.\n"
19951995
"Maybe use '%[2]s'?"
19961996

1997-
#: cli/config/remove.go:51
1997+
#: cli/config/remove.go:54
19981998
msgid "The key '%[1]v' is not a list of items, can't remove from it.\n"
19991999
"Maybe use '%[2]s'?"
20002000
msgstr "The key '%[1]v' is not a list of items, can't remove from it.\n"
@@ -2347,7 +2347,7 @@ msgstr "Writes current configuration to a configuration file."
23472347
msgid "Writes current configuration to the configuration file in the data directory."
23482348
msgstr "Writes current configuration to the configuration file in the data directory."
23492349

2350-
#: cli/config/set.go:76
2350+
#: cli/config/set.go:79
23512351
msgid "Writing config file: %v"
23522352
msgstr "Writing config file: %v"
23532353

@@ -2568,7 +2568,7 @@ msgstr "encoding sketch metadata: %s"
25682568
msgid "error opening serial monitor"
25692569
msgstr "error opening serial monitor"
25702570

2571-
#: cli/config/set.go:68
2571+
#: cli/config/set.go:71
25722572
msgid "error parsing value: %v"
25732573
msgstr "error parsing value: %v"
25742574

0 commit comments

Comments
 (0)