-
Notifications
You must be signed in to change notification settings - Fork 34
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
Supports fish shell #174
base: main
Are you sure you want to change the base?
Supports fish shell #174
Conversation
Signed-off-by: Tin Lai <[email protected]>
for more information, see https://pre-commit.ci
Result: $ shtab --shell=fish shtab.main.get_main_parser # AUTOMATICALLY GENERATED by `shtab`
complete -c shtab -n __fish_use_subcommand -s h -l help -d 'show this help message and exit'
complete -c shtab -n __fish_use_subcommand -l version -d 'show program\'s version number and exit'
complete -c shtab -n __fish_use_subcommand -s s -l shell -a '(printf "%s\t%s\n" bash shell zsh shell tcsh shell fish shell)' -x
complete -c shtab -n __fish_use_subcommand -l prefix -d 'prepended to generated functions to avoid clashes'
complete -c shtab -n __fish_use_subcommand -l preamble -d 'prepended to generated script'
complete -c shtab -n __fish_use_subcommand -l prog -d 'custom program name (overrides `parser.prog`)'
complete -c shtab -n __fish_use_subcommand -s u -l error-unimportable -d 'raise errors if `parser` is not found in $PYTHONPATH'
complete -c shtab -n __fish_use_subcommand -l verbose -d 'Log debug information'
complete -c shtab -n __fish_use_subcommand -l print-own-completion -d 'print shtab\'s own completion' -a '(printf "%s\t%s\n" bash print_own_completion zsh print_own_completion tcsh print_own_completion fish print_own_completion)' -x $ shtab --shell=fish tmuxp.cli.create_parser # AUTOMATICALLY GENERATED by `shtab`
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s L -d 'passthru to tmux(1) -L'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s S -d 'passthru to tmux(1) -S'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s f -d 'passthru to tmux(1) -f'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s s -d 'start new session with new session name'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s y -l yes -d 'always answer yes'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s d -d 'load the session without attaching it'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s a -l append -d 'load workspace, appending windows to the current session'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s 2 -d 'force tmux to assume the terminal supports 256 colours.'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -s 8 -d 'like -2, but indicates that the terminal supports 88 colours.'
complete -c tmuxp -n '__fish_seen_subcommand_from load' -l log-file -d 'file to log errors/output to'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -s S -d 'pass-through for tmux -S'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -s L -d 'pass-through for tmux -L'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -s c -d 'instead of opening shell, execute python code in libtmux and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l best -d 'use best shell available in site packages'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l pdb -d 'use plain pdb'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l code -d 'use stdlib\'s code.interact()'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l ptipython -d 'use ptpython + ipython'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l ptpython -d 'use ptpython'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l ipython -d 'use ipython'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l bpython -d 'use bpython'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l use-pythonrc -d 'load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l no-startup -d 'load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l use-vi-mode -d 'use vi-mode in ptpython/ptipython'
complete -c tmuxp -n '__fish_seen_subcommand_from shell' -l no-vi-mode -d 'use vi-mode in ptpython/ptipython'
complete -c tmuxp -n '__fish_seen_subcommand_from import teamocil' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from import tmuxinator' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from import' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from convert' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from convert' -s y -l yes -d 'always answer yes'
complete -c tmuxp -n '__fish_seen_subcommand_from debug-info' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from ls' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from edit' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s S -d 'pass-through for tmux -S'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s L -d 'pass-through for tmux -L'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s f -l workspace-format -d 'format to save in' -a '(printf "%s\t%s\n" yaml workspace_format json workspace_format)' -x
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s o -l save-to -d 'file to save to'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s y -l yes -d 'always answer yes'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -s q -l quiet -d 'don\'t prompt for confirmation'
complete -c tmuxp -n '__fish_seen_subcommand_from freeze' -l force -d 'overwrite the workspace file'
complete -c tmuxp -n __fish_use_subcommand -s h -l help -d 'show this help message and exit'
complete -c tmuxp -n __fish_use_subcommand -s V -l version -d 'show program\'s version number and exit'
complete -c tmuxp -n __fish_use_subcommand -l log-level -d 'log level (debug, info, warning, error, critical) (default "info")' -a '(printf "%s\t%s\n" debug log_level info log_level warning log_level error log_level critical log_level)' -x
complete -c tmuxp -n '__fish_seen_subcommand_from import' -a '(printf "%s\t%s\n" teamocil "convert and import a teamocil config" tmuxinator "convert and import a tmuxinator config")' -x
complete -c tmuxp -n __fish_use_subcommand -a '(printf "%s\t%s\n" load "load tmuxp workspaces" shell "launch python shell for tmux server, session, window and pane" import "import workspaces from teamocil and tmuxinator." convert "convert workspace files between yaml and json." debug-info "print out all diagnostic info" ls "list workspaces in tmuxp directory" edit "run $EDITOR on workspace file" freeze "freeze a live tmux session to a tmuxp workspace file")' -x |
Thanks for this! There are a few failing tests though... _______________________ test_main_self_completion[fish] ________________________
tests/test_shtab.py:79: in test_main_self_completion
assert expected[shell] in captured.out
E KeyError: 'fish'
___________________________ test_prog_scripts[fish] ____________________________
tests/test_shtab.py:115: in test_prog_scripts
raise NotImplementedError(shell)
E NotImplementedError: fish
________________________ test_positional_choices[fish] _________________________
tests/test_shtab.py:154: in test_positional_choices
completion = shtab.complete(parser, shell=shell)
shtab/__init__.py:970: in complete
return completer(
shtab/__init__.py:932: in complete_fish
option_strings, choices = get_fish_commands(parser, choice_functions=choice_functions)
shtab/__init__.py:920: in get_fish_commands
recurse(root_parser)
shtab/__init__.py:882: in recurse
choices_to_action = {v.dest: v.help for v in positional._choices_actions}
E AttributeError: '_StoreAction' object has no attribute '_choices_actions'
____________________ test_add_argument_to_positional[fish] _____________________
tests/test_shtab.py:287: in test_add_argument_to_positional
completion_manual = shtab.complete(parser, shell=shell)
shtab/__init__.py:970: in complete
return completer(
shtab/__init__.py:932: in complete_fish
option_strings, choices = get_fish_commands(parser, choice_functions=choice_functions)
shtab/__init__.py:920: in get_fish_commands
recurse(root_parser)
shtab/__init__.py:899: in recurse
recurse(
shtab/__init__.py:882: in recurse
choices_to_action = {v.dest: v.help for v in positional._choices_actions}
E AttributeError: 'PrintCompletionAction' object has no attribute '_choices_actions' |
fish shell completion is painful when you have subcommand and sub-subcommands (eg: I’ll try tomorrow, it would be quite useful for me if it works. |
Signed-off-by: Tin Lai <[email protected]>
…to feat-support-fish-shell
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
==========================================
+ Coverage 88.88% 89.63% +0.75%
==========================================
Files 3 3
Lines 360 444 +84
==========================================
+ Hits 320 398 +78
- Misses 40 46 +6 ☔ View full report in Codecov by Sentry. |
Closes #134