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

zsh sub-subcommand recursion #33

Closed
skshetry opened this issue Mar 3, 2021 · 4 comments · Fixed by #73
Closed

zsh sub-subcommand recursion #33

skshetry opened this issue Mar 3, 2021 · 4 comments · Fixed by #73
Assignees
Labels

Comments

@skshetry
Copy link
Member

skshetry commented Mar 3, 2021

shtab does not seem to provide autocompletion for subcommands for zsh, whereas it does so for the bash. Only the parent's flags are shown (-h/-q/-v in the DVC's case).

def recurse(parser, prefix):

@casperdcl
Copy link
Collaborator

works for me?

% dvc add -<TAB>
Completing option
--desc           -- User description of the data (optional). This doesn't affect any DVC operations
--external       -- Allow targets that are outside of the DVC repository.
...
--verbose    -v  -- Be verbose.

@casperdcl casperdcl added p0-critical Max priority (ASAP) invalid Doesn't seem right shell-zsh labels Aug 25, 2021
@skshetry
Copy link
Member Author

skshetry commented Aug 26, 2021

@casperdcl, it's about sub-subcommand autocompletion as shtab does not recurse on them.

$ dvc exp show -<TAB>
--help     -h  -- show this help message and exit
--quiet    -q  -- Be quiet.
--verbose  -v  -- Be verbose.

As you can see, it's only listing flags on the parent parser, whereas exp show has these many flags:

options:
  -h, --help            show this help message and exit
  -q, --quiet           Be quiet.
  -v, --verbose         Be verbose.
  -a, --all-branches    Show experiments derived from the tip of all Git
                        branches.
  -T, --all-tags        Show experiments derived from all Git tags.
  -A, --all-commits     Show experiments derived from all Git commits.
  -n <num>, --num <num>
                        Show the last `num` commits from HEAD.
  --no-pager            Do not pipe output into a pager.
  --include-metrics <metrics_list>
                        Include the specified metrics in output table.
  --exclude-metrics <metrics_list>
                        Exclude the specified metrics from output table.
  --include-params <params_list>
                        Include the specified params in output table.
  --exclude-params <params_list>
                        Exclude the specified params from output table.
  --param-deps          Show only params that are stage dependencies.
  --sort-by <metric/param>
                        Sort related experiments by the specified metric or
                        param.
  --sort-order {asc,desc}
                        Sort order to use with --sort-by.
  --no-timestamp        Do not show experiment timestamps.
  --sha                 Always show git commit SHAs instead of branch/tag
                        names.
  --show-json           Print output in JSON format instead of a human-
                        readable table.
  --precision <n>       Round metrics/params to `n` digits precision after the
                        decimal point. Rounds to 5 digits by default.

I do get the autocompletion in bash:

$ dvc exp show --<TAB>
--all-branches     --help             --num              --show-json
--all-commits      --include-metrics  --param-deps       --sort-by
--all-tags         --include-params   --precision        --sort-order
--exclude-metrics  --no-pager         --quiet            --verbose
--exclude-params   --no-timestamp     --sha

@casperdcl casperdcl removed the invalid Doesn't seem right label Aug 28, 2021
@casperdcl casperdcl changed the title shtab does not support subcommands autocompletion for zsh zsh sub-subcommand recursion Aug 28, 2021
@casperdcl casperdcl self-assigned this Aug 28, 2021
@casperdcl casperdcl added the help-wanted We need help label Sep 1, 2021
@casperdcl casperdcl added p1-important High priority and removed p0-critical Max priority (ASAP) labels Nov 16, 2021
@skshetry
Copy link
Member Author

@casperdcl, do you have any good resource/documentation on zsh autocompletion, especially something that's a bit complicated?

@casperdcl
Copy link
Collaborator

casperdcl commented Jan 16, 2022

None that I know of; plus I don't use zsh otherwise I would've implemented this ages ago :)

I think the official docs are at https://zsh.sourceforge.io/Doc/Release/Completion-System.html

Feel free to take a s(h)tab at it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants