Skip to content
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

bash: Multiple subparser commands don't complete correctly #86

Closed
NiklasReisser opened this issue Aug 5, 2022 · 6 comments · Fixed by #106
Closed

bash: Multiple subparser commands don't complete correctly #86

NiklasReisser opened this issue Aug 5, 2022 · 6 comments · Fixed by #106
Assignees
Labels
external-request You asked, we did p0-critical Max priority (ASAP) shell-bash

Comments

@NiklasReisser
Copy link

Hi,

since #81 , shtab always only completes the first subparser command. The minimal example below immediately completes "bla".

The Reason seems to be that

current_action_choices="${!current_action_choices_var}"

only expands the first value of the _choices array. Unfortunately, I have not found a solution without breaking #81 again.
Happy to try any idea though.


#!/usr/bin/env python3

import argparse
import shtab

parser = argparse.ArgumentParser()
shtab.add_argument_to(parser, ["--print-completion"])

subparsers = parser.add_subparsers()

subparser1 = subparsers.add_parser('bla', help="hi")
subparser2 = subparsers.add_parser('blub', help="hi")

args = parser.parse_args()

Cheers
Niklas

@pared
Copy link

pared commented Oct 26, 2022

@pared pared added this to DVC Oct 26, 2022
@pared pared moved this to Backlog in DVC Oct 26, 2022
@pared pared moved this from Backlog to Todo in DVC Oct 26, 2022
@alkatar21
Copy link

I have the Issue with DVC tab completion.

Current workaround as suggested in Discord is:

  1. Downgrade shtab (pip install shtab==1.5.4)
  2. dvc completion -s bash | sudo tee /etc/bash_completion.d/dvc
  3. reload terminal/ open a new one, try again

@casperdcl
Copy link
Collaborator

Related: #106

@casperdcl casperdcl linked a pull request Oct 29, 2022 that will close this issue
@casperdcl casperdcl self-assigned this Oct 29, 2022
@casperdcl casperdcl added p0-critical Max priority (ASAP) external-request You asked, we did labels Oct 29, 2022
Repository owner moved this from Todo to Done in DVC Oct 29, 2022
@shcheklein
Copy link
Member

@casperdcl thanks! :)

@shcheklein
Copy link
Member

@alkatar21 could you give the new version a try?

@alkatar21
Copy link

Yes, the subcommands autocomplete correct again, thanks👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-request You asked, we did p0-critical Max priority (ASAP) shell-bash
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants