From 671c7c2d066619dcc35322cea100b4f94aac3bca Mon Sep 17 00:00:00 2001 From: Atri Bhattacharya Date: Wed, 28 Feb 2024 23:38:56 +0530 Subject: [PATCH] fix: several improvements to shell completions. * bash: Sort possible latexmk-tex arguments. * fish: Make descriptions consistent with others, correct spelling issues, include a missed option (`--completion`). * zsh: Allow exclusion of options based on those already used by grouping sets of options together. --- src/tartex/_parse_args.py | 2 +- src/tartex/data/tartex-completion.bash | 2 +- src/tartex/data/tartex-completion.fish | 34 ++++++++++----------- src/tartex/data/tartex-completion.zsh | 42 ++++++++++++++------------ 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/tartex/_parse_args.py b/src/tartex/_parse_args.py index 7b3d3e2..84e56e2 100644 --- a/src/tartex/_parse_args.py +++ b/src/tartex/_parse_args.py @@ -365,7 +365,7 @@ def parse_args(args): tar_opts = parser.add_mutually_exclusive_group() def cmp_str(cmp, ext): - return f"Recompress with {cmp} (.{ext})" " (overrides .SUF in '-o')" + return f"recompress with {cmp} (.{ext})" " (overrides .SUF in '-o')" tar_opts.add_argument( "-j", diff --git a/src/tartex/data/tartex-completion.bash b/src/tartex/data/tartex-completion.bash index af04b55..b86cf28 100644 --- a/src/tartex/data/tartex-completion.bash +++ b/src/tartex/data/tartex-completion.bash @@ -29,7 +29,7 @@ _tartex_completions() ;; --latexmk-tex) - COMPREPLY=($(compgen -W "dvi luatex lualatex pdf pdflua ps xdv xelatex" -- "$cur")) + COMPREPLY=($(compgen -W "dvi lualatex luatex pdf pdflua ps xdv xelatex" -- "$cur")) return ;; diff --git a/src/tartex/data/tartex-completion.fish b/src/tartex/data/tartex-completion.fish index 85d3984..e5262d1 100644 --- a/src/tartex/data/tartex-completion.fish +++ b/src/tartex/data/tartex-completion.fish @@ -3,31 +3,31 @@ complete -c tartex -r -k -f -a "(__fish_complete_suffix .tex .fls)" # Options that take an argument complete -c tartex -s o -l output -f -r \ - -d "Name of output tar NAME[.SUF] (.SUF may set tar compression)" \ + -d "output tar file name (suffix may set tar compression)" \ -k -a "(__fish_complete_suffix .tar.gz .tar.bz2 .tar.xz)" -complete -c tartex -f -l latexmk-tex -ra "dvi luatex lualatex pdf pdflua ps xdv xelatex" \ - -d "Force TeX processing mode used by latexmk" +complete -c tartex -f -l latexmk-tex -ra "dvi lualatex luatex pdf pdflua ps xdv xelatex" \ + -d "force TeX processing mode used by latexmk" complete -c tartex -s a -l add -F -r complete -c tartex -s x -l excl -F -r # Help/Version options -complete -c tartex -s h -l help -d "Display help for tartex and exit" -complete -c tartex -s V -l Version -d "Display tartex version and exit" +complete -c tartex -s h -l help -d "display help for tartex and exit" +complete -c tartex -s V -l Version -d "display tartex version and exit" # Options that act as flags (no arguments) -complete -c tartex -f -s b -l bib -d "Include bibliography (.bib) file in tar" -complete -c tartex -f -s v -l verbose -d "Increase verbosity of output (may be used multiple times)" -complete -c tartex -f -s s -l summary -d "Print a summary at the end" -complete -c tartex -f -s b -l bib -d "Include bibliography (.bib) file in tar" -complete -c tartex -f -s l -l list -d "Print a list of files to include and quit (no tarball generated)" -complete -c tartex -f -s F -l force-recompile -d "Force recompilation even if .fls exists" +complete -c tartex -f -s b -l bib -d "include bibliography (.bib) file in tar" +complete -c tartex -f -s F -l force-recompile -d "force recompilation even if .fls exists" +complete -c tartex -f -s l -l list -d "print a list of files to include and quit" +complete -c tartex -f -s s -l summary -d "print a summary at the end" +complete -c tartex -f -s v -l verbose -d "increase verbosity (-v, -vv, etc.)" # Compression options -complete -c tartex -f -s j -l bzip2 -d "Re-compress output tar with bzip2" -complete -c tartex -f -s z -l gzip -d "Re-compress output tar with gzip" -complete -c tartex -f -s J -l xz -d "Re-compress output tar with xz" +complete -c tartex -f -s j -l bzip2 -d "compress output with bzip2" +complete -c tartex -f -s z -l gzip -d "compress output with gzip" +complete -c tartex -f -s J -l xz -d "compress output with xz" # Completions -complete -c tartex -f -l bash-completion -d "Install bash completions for tartex" -complete -c tartex -f -l fish-completion -d "Install fish completions for tartex" -complete -c tartex -f -l zsh-completion -d "Install zsh completions for tartex" +complete -c tartex -f -l completion -d "print shell completion guides for tartex" +complete -c tartex -f -l bash-completions -d "install bash completions for tartex" +complete -c tartex -f -l fish-completions -d "install fish completions for tartex" +complete -c tartex -f -l zsh-completions -d "install zsh completions for tartex" diff --git a/src/tartex/data/tartex-completion.zsh b/src/tartex/data/tartex-completion.zsh index a718d7c..54f7d2e 100644 --- a/src/tartex/data/tartex-completion.zsh +++ b/src/tartex/data/tartex-completion.zsh @@ -38,23 +38,27 @@ typeset -A opt_args tar_ext="*.tar.(bz2|gz|xz)" _arguments -s -S \ - '(- *)'{-h,--help}'[show this help message and exit]' \ - '(-a --add)'{-a,--add=}'[Include additional file names matching glob-style PATTERNS]:PATTERNS:_files' \ - '(-b --bib)'{-b,--bib}'[find and add bib file to tarball]' \ - '(-l --list)'{-l,--list}'[Print a list of files to include and quit (no tarball generated)]' \ - '(-o --output)'{-o,--output=}'[Name of output tar]:FILENAME:_files -g "$tar_ext"' \ - '(-s --summary)'{-s,--summary}'[Print a summary at the end]' \ - '(-v --verbose)'{-v,--verbose}'[Print file names added to tarball]' \ - '(-x --excl)'{-x,--excl=}'[Exclude file names matching PATTERNS]:PATTERNS:_files' \ - '(-j --bzip2)'{-j,--bzip2}'[bzip2 (.tar.bz2) compression (overrides other compression settings)]' \ - '(-J --xz)'{-J,--xz}'[lzma (.tar.xz) compression (overrides other compression settings)]' \ - '(-z --gzip)'{-z,--gzip}'[gzip (.tar.gz) compression (overrides other compression settings)]' \ - '(- *)'{-V,--version}'[Print tartex version]' \ - '--latexmk-tex=[Force TeX processing mode used by latexmk]:TEXMODE:(dvi luatex lualatex pdf pdflua ps xdv xelatex)' \ - '(-F --force-recompile)'{-F,--force-recompile}'[Force recompilation even if .fls exists]' \ - '--completion[Print bash completion for tartex]' \ - '--bash-completion[Install bash completions for tartex]' \ - '--fish-completion[Install fish completions for tartex]' \ - '--zsh-completion[Install zsh completions for tartex]' \ - '*:INPUT_FILE:_files -g "*.(fls|tex)"' && ret=0 + '(completions):INPUT_FILE:_files -g "*.(fls|tex)"' \ + '(- : *)'{-h,--help}'[show this help message and exit]' \ + '(- : *)'{-V,--version}'[print tartex version and exit]' \ + '(completions -a --add)'{-a,--add=}'[include additional file names matching glob-style PATTERNS]:PATTERNS:_files' \ + '(completions -b --bib)'{-b,--bib}'[find and add bib file to tarball]' \ + '(completions -s --summary)'{-s,--summary}'[print a summary at the end]' \ + '*'{-v,--verbose}'[increase verbosity (-v, -vv, etc.)]' \ + '(completions -x --excl)'{-x,--excl=}'[exclude file names matching PATTERNS]:PATTERNS:_files' \ + '(completions --latexmk-tex)--latexmk-tex=[force TeX processing mode used by latexmk]:TEXMODE:(dvi lualatex luatex pdf pdflua ps xdv xelatex)' \ + '(completions -F --force-recompile)'{-F,--force-recompile}'[force recompilation even if .fls exists]' \ + + '(completions)' \ + '(- : *)--completion[print shell completion guides for tartex]' \ + '(- : *)--bash-completions[install bash completions for tartex]' \ + '(- : *)--fish-completions[install fish completions for tartex]' \ + '(- : *)--zsh-completions[install zsh completions for tartex]' \ + + '(compression)' \ + '(completions -l --list)'{-j,--bzip2}'[compress output with bzip2 (.bz2)]' \ + '(completions -l --list)'{-z,--gzip}'[compress output with gzip (.gz)]' \ + '(completions -l --list)'{-J,--xz}'[compress output with lzma (.xz)]' \ + + '(output)' \ + '(completions compression -l --list)'{-l,--list}'[print a list of files to include and quit]' \ + '(completions -o --output)'{-o,--output=}'[name of output tar file]:FILENAME:_files -g "$tar_ext"' \ + && ret=0 return ret