I for example have dvc stage add --name Test -d folder/file -w and want to remove folder/file and replace it. Than -w is autocompleted (dvc stage add --name Test -d -w -w) instead of an option for folders.
So for some reason the autocompletion with tab adds a -w instead of autocompletion for files and folders in this case. But the autocompletion works if nothing follows after -d.
This gif shows the behavior:
An reproducable example is the following provided by pared#9484 on the Discord server:
#!/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")
subparser1.add_argument(
"-d",
"--directory",
action="store",
required=True,
dest="dir",
help="this is directory",
).complete = shtab.DIRECTORY # type: ignore
subparser1.add_argument(
"-w",
"--wdir",
help="Directory within your repo to run your command in.",
metavar="<path>",
)
subparser2 = subparsers.add_parser('blub', help="hi")
args = parser.parse_args()
dvc==2.31.0 shtab==1.5.6
I for example have
dvc stage add --name Test -d folder/file -w
and want to removefolder/file
and replace it. Than-w
is autocompleted (dvc stage add --name Test -d -w -w
) instead of an option for folders. So for some reason the autocompletion with tab adds a-w
instead of autocompletion for files and folders in this case. But the autocompletion works if nothing follows after-d
. This gif shows the behavior:An reproducable example is the following provided by pared#9484 on the Discord server:
Further context: https://discord.com/channels/485586884165107732/485596304961962003/1036650841425313843