Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b6acdec

Browse files
committed
use newer and supported bashv2 completion in order to have dynamic completion
1 parent 2b4c96b commit b6acdec

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

‎cli/completion/completion.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ func NewCommand() *cobra.Command {
4747
}
4848

4949
func run(cmd *cobra.Command, args []string) {
50-
if completionNoDesc && (args[0] == "bash"||args[0] =="powershell") {
50+
if completionNoDesc && (args[0] == "powershell") {
5151
feedback.Errorf(tr("Error: command description is not supported by %v"), args[0])
5252
os.Exit(errorcodes.ErrGeneric)
5353
}
5454
switch args[0] {
5555
case "bash":
56-
cmd.Root().GenBashCompletion(os.Stdout)
56+
cmd.Root().GenBashCompletionV2(os.Stdout, !completionNoDesc)
5757
break
5858
case "zsh":
5959
if completionNoDesc {

‎test/test_completion.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_completion_bash(run_command):
2525
result = run_command("completion bash")
2626
assert result.ok
2727
assert result.stderr == ""
28-
assert "_arduino-cli_root_command()" in result.stdout
28+
assert "# bash completion V2 for arduino-cli" in result.stdout
2929
assert "__start_arduino-cli()" in result.stdout
3030

3131

@@ -55,9 +55,11 @@ def test_completion_powershell(run_command):
5555

5656
def test_completion_bash_no_desc(run_command):
5757
result = run_command("completion bash --no-descriptions")
58-
assert not result.ok
59-
assert result.stdout == ""
60-
assert "Error: command description is not supported by bash" in result.stderr
58+
assert result.ok
59+
assert result.stderr == ""
60+
assert "# bash completion V2 for arduino-cli" in result.stdout
61+
assert "__start_arduino-cli()" in result.stdout
62+
assert "__completeNoDesc" in result.stdout
6163

6264

6365
def test_completion_zsh_no_desc(run_command):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /