Skip to content

add dynamic completion #1509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9d61a6e
add completion for `-b` or `--fqbn` for every command
umbynos Oct 18, 2021
b7263bf
add completion for `-l` or `--protocol`
umbynos Oct 18, 2021
b6ed62f
the previous implementation was working only with a board connected t…
umbynos Oct 5, 2021
3e57b18
add static completion for `--log-level, `--log-format` and `--format`
umbynos Oct 6, 2021
0c0823f
add completion for `-P` or `--programmer` & fix typo
umbynos Oct 6, 2021
fe4ab51
add completion for `core uninstall`
umbynos Oct 6, 2021
fc82c12
add completion for `core install` and `core download`
umbynos Oct 6, 2021
e79ae01
add completion for `lib uninstall`
umbynos Oct 6, 2021
6d560b2
add completion for `lib install`, `lib download`
umbynos Oct 7, 2021
3486d94
add completion for `lib examples`
umbynos Oct 7, 2021
28dfdc1
add completion for `config add`, `config remove`, `config delete` and…
umbynos Oct 7, 2021
27d300c
add completion for `lib deps`
umbynos Oct 7, 2021
d7be814
add tests
umbynos Oct 12, 2021
4559c25
enhance the completion for `config add` and `config remove`
umbynos Oct 13, 2021
6b1a01c
add description completion suggestion for core, lib, fqbn, programmer
umbynos Oct 13, 2021
5462031
add completion also for `-p` or `--port` flag
umbynos Oct 13, 2021
fe2cf65
remove the `toComplete` parameter from all the completion functions
umbynos Oct 13, 2021
2a953a9
fixes after rebase
umbynos Oct 13, 2021
7235896
update docs
umbynos Oct 13, 2021
d6c4732
add `-b` or `--fqbn` completion for the monitor command and tests
umbynos Oct 14, 2021
c5ee4d0
apply suggestions from code review
umbynos Oct 15, 2021
d6d4502
fixes after rebase
umbynos Oct 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add completion for config add, config remove, config delete and…
… `config set`
  • Loading branch information
umbynos committed Oct 18, 2021
commit 28dfdc1583b59b16fec8cda450efdb2cc1666e2a
3 changes: 3 additions & 0 deletions cli/config/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func initAddCommand() *cobra.Command {
" " + 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",
Args: cobra.MinimumNArgs(2),
Run: runAddCommand,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
},
}
return addCommand
}
Expand Down
3 changes: 3 additions & 0 deletions cli/config/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func initDeleteCommand() *cobra.Command {
" " + os.Args[0] + " config delete board_manager.additional_urls",
Args: cobra.ExactArgs(1),
Run: runDeleteCommand,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
},
}
return addCommand
}
Expand Down
3 changes: 3 additions & 0 deletions cli/config/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func initRemoveCommand() *cobra.Command {
" " + 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",
Args: cobra.MinimumNArgs(2),
Run: runRemoveCommand,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
},
}
return addCommand
}
Expand Down
3 changes: 3 additions & 0 deletions cli/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func initSetCommand() *cobra.Command {
" " + os.Args[0] + " config set board_manager.additional_urls https://example.com/package_example_index.json https://another-url.com/package_another_index.json",
Args: cobra.MinimumNArgs(2),
Run: runSetCommand,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return configuration.Settings.AllKeys(), cobra.ShellCompDirectiveDefault
},
}
return addCommand
}
Expand Down
18 changes: 9 additions & 9 deletions i18n/data/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ msgstr "Can't find dependencies for platform %s"
msgid "Can't open sketch"
msgstr "Can't open sketch"

#: cli/config/set.go:54
#: cli/config/set.go:57
msgid "Can't set multiple values in key %v"
msgstr "Can't set multiple values in key %v"

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

#: cli/config/add.go:60
#: cli/config/delete.go:67
#: cli/config/remove.go:69
#: cli/config/add.go:63
#: cli/config/delete.go:70
#: cli/config/remove.go:72
msgid "Can't write config file: %v"
msgstr "Can't write config file: %v"

Expand Down Expand Up @@ -1822,7 +1822,7 @@ msgstr "Sets a setting value."
msgid "Sets where to save the configuration file."
msgstr "Sets where to save the configuration file."

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

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

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

#: cli/config/set.go:76
#: cli/config/set.go:79
msgid "Writing config file: %v"
msgstr "Writing config file: %v"

Expand Down Expand Up @@ -2568,7 +2568,7 @@ msgstr "encoding sketch metadata: %s"
msgid "error opening serial monitor"
msgstr "error opening serial monitor"

#: cli/config/set.go:68
#: cli/config/set.go:71
msgid "error parsing value: %v"
msgstr "error parsing value: %v"

Expand Down