Closed Freed-Wu closed 1 year ago
Thanks for the pull request. Thank you also for the updated documentation. Before merging, the following issues need to be resolved.
--print-completion
option entry to the expected help text in the test case--print-completion
option addition. Please do not add new long or short options (--config
or -W
) to the existing onesspec
) that performs the following checks on the feature
--print-completion zsh
outputs the expected content and exits successfully--print-completion
receives an argument that it does not support (e.g., fish
at this time), it should fail with the appropriate error message--print-completion zsh
is valid as a zsh script (optional but strongly desired)--print-completion zsh
actually completes correctly (optional)I have removed all added option except --print-competition
and a prompt fish is not supported currently
is added, too.
I am not familiar with ruby :cry: Can you provide some help?
I have removed all added option except
--print-competition
and a promptfish is not supported currently
is added, too.
Thank you :+1:
I am not familiar with ruby 😢 Can you provide some help?
Well, how can I help you? You can add spec/action/print_completion_spec.rb
to check the following:
--print-completion zsh
outputs the expected content and exits successfully- If
--print-completion
receives an argument that it does not support (e.g.,fish
at this time), it should fail with the appropriate error message- The output
--print-completion zsh
is valid as a zsh script (optional but strongly desired)- The output completion function of
--print-completion zsh
actually completes correctly (optional)
At least the first two should be easy if you imitate spec/action/help_spec.rb
. For the rest, you can have a try, but you can leave them as they are optional.
We still have some failing test cases. I'm afraid these are not because of the test Ruby code issues, but some incompatible behavior of your Lua code.
Now all tests have passed. :smile:
Can you add the test specs? I try but failed. If I add new test rake test
will fail.
❯ rake test
texlua /dev/shm/texdoc/script/texdoc.tlu -f
/dev/shm/texdoc/tmp/texmf/scripts/texdoc/texdoclib.tlu 3.4.1
Configuration file(s):
active /home/wzy/.texlive/texmf-config/texdoc/texdoc.cnf
active /dev/shm/texdoc/tmp/texmf/texdoc/texdoc.cnf
active /dev/shm/texdoc/tmp/texmf/texdoc/texdoc-dist.cnf
disabled /usr/share/texmf-dist/texdoc/texdoc.cnf
Recommended file(s) for personal settings:
/dev/shm/texdoc/tmp/texmf/texdoc/texdoc.cnf
bundle exec rspec
...................................................................................
Finished in 1 minute 50.49 seconds (files took 0.1214 seconds to load)
83 examples, 0 failures
Thanks for your large effort! Now I tested your code locally:
$ texdoc --print-completion zsh
.../scripts/texdoc/texdoclib-cli.tlu:116: attempt to concatenate a boolean value (local 'v')
$ texdoc --print-completion=zsh
compdef __texdoc texdoc
__texdoc() {
local options=(
"(- : *)"{-h,--help}"[Print this help message.]"
"(- : *)"{-V,--version}"[Print the version number.]"
"(- : *)"{-f,--files}"[Print the list of configuration files used.]"
"(- : *)"--just-view"[Display FILE, given with full path (no searching).]: :_files"
"(- : *)"--print-completion"[Print SHELL completion.]:shell:(zsh)"
+ mode
"(mode)"{-w,--view}"[Use view mode: start a viewer. (default)]"
"(mode)"{-m,--mixed}"[Use mixed mode (view or list).]"
"(mode)"{-l,--list}"[Use list mode: show a list of results.]"
"(mode)"{-s,--showall}"[Use showall mode: show also "bad" results.]"
+ interaction
"(interaction)"{-i,--interact}"[Use interactive menus. (default)]"
"(interaction)"{-I,--nointeract}"[Use plain lists, no interaction required.]"
"(interaction)"{-M,--machine}"[Machine-readable output for lists (implies -I).]"
+ debug
"(debug)"{-q,--quiet}"[Suppress warnings and most error messages.]"
"(debug)"{-v,--verbose}"[Print additional information (e.g., viewer command).]"
"(debug)"-D"[Activate all debug output (equal to "--debug=all").]"
"(debug)"{-d,--debug=-}"[Activate debug output restricted to LIST.]:list:(config tlpdb view texdocs version files search score)"
"(debug)"-c"[Set configuration item NAME to VALUE.]:name=value:(viewer_ mode interact_switch machine_switch ext_list basename_list badext_list badbasename_list suffix_list verbosity_level debug_list lastfile_switch rm_dir rm_file unzip_ zipext_list max_lines lang fuzzy_level texlive_tlpdb online_url)"
)
_arguments -C -A $options \
'*: :->arguments' && return
case $state in
arguments)
local tlpdb="$(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb"
_values package $(awk '/^name[^.]*$/ {print $2}' $tlpdb)
;;
esac
}
It seems the =
sign is required, but it differs from what you described in the help text.
Also, the following case should print an appropriate error message
$ texdoc --print-completion
.../scripts/texdoc/texdoclib-cli.tlu:116: attempt to concatenate a boolean value (local 'v')
just like:
$ texdoc --just-view
texdoc error: Missing file operand to --just-view.
texdoc error: Try `texdoc --help' for short help, `texdoc texdoc' for full manual.
I wrote the simple spec (1bf47ec76013ce65cb49beffa2a32d0373d7fed1). You can copy the file from this commit.
This test case is failing due to the above =
sign requirement issue. Please fix it so that to pass this test case.
Apart from the above, I think this pull request is almost ready to be merged.
Great 👍
Thanks for your hard work.
For convenience to realize, now every option has a short name and a long name: -c, --config -W, --just-view -S, --print-completion Update man page and pdf Add install completion method in pdf Use
texdoc.config.options
to generate help text and shell completion script Add stop_completion intexdoc.config.options
, such as--view
will stop--list
,--showall
,--mixed
, ... due to all of them change modetexdoc --just-view
will complete files whiletexdoc --other-option
will complete package namestexdoc [OPTION]... ACTION
will stop all other options and arguments.There are many changes so reviewing the code maybe also cost a long time, which I am very sorry to occupy your time.
Included. See
texdoc.config.options
.