Skip to content

Commit

Permalink
fix: several improvements to shell completions.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
badshah400 committed Feb 28, 2024
1 parent 6b58655 commit 671c7c2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/tartex/_parse_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/tartex/data/tartex-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;

Expand Down
34 changes: 17 additions & 17 deletions src/tartex/data/tartex-completion.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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"
42 changes: 23 additions & 19 deletions src/tartex/data/tartex-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 671c7c2

Please sign in to comment.