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

[feature] Can texdoc has a shell completion for bash/zsh/...? #89

Closed
Freed-Wu opened this issue Jan 19, 2023 · 9 comments
Closed

[feature] Can texdoc has a shell completion for bash/zsh/...? #89

Freed-Wu opened this issue Jan 19, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@Freed-Wu
Copy link
Contributor

That is, user can eval $(texdoc --print-completion XXsh) in their bashrc/zshrc then

$ texdoc -<TAB>
option
-c             Set configuration item NAME to VALUE.
-D             Activate all debug output (equal to "--debug=all").
--debug        Activate all debug output (equal to "--debug=all").
-d             LIST, --debug=LIST
--files        Print the list of configuration files used.
...

TIA!

@wtsnjp
Copy link
Member

wtsnjp commented Jan 19, 2023

Please refer to our wiki: https://github.com/TeX-Live/texdoc/wiki/Tab-completion

@wtsnjp wtsnjp closed this as completed Jan 19, 2023
@Freed-Wu
Copy link
Contributor Author

Freed-Wu commented Jan 19, 2023

Oh, I thought the code stores the option names and option help text in a data structure, then use the data structure to parse command line input and generate
help text from a template like https://github.com/latex3/l3build/blob/main/l3build-help.lua#L41-L93. If so, we can generate completion script from
a template and add a new option to print the script like
--help to print help text. However, there doesn't exist this data structure.
This code just use a written manually help text
https://github.com/TeX-Live/texdoc/blob/master/script/texdoclib-const.tlu#L38-L58
And parse command line input by many if-clauses in
https://github.com/TeX-Live/texdoc/blob/master/script/texdoclib-cli.tlu#L101-L146

So I think if it is hard to generate shell scripts except there are some one would
rather to write one manually like
https://gist.github.com/wtsnjp/07d2b4acb04d5286d12d10d6021c2716. And this
written manually script must be updated when the new option be added, which is
usually out-of-time, compared to the script generated from a template.

@wtsnjp wtsnjp reopened this Jan 19, 2023
@Freed-Wu
Copy link
Contributor Author

Freed-Wu commented Jan 19, 2023

@wtsnjp wtsnjp added the enhancement New feature or request label Jan 20, 2023
@wtsnjp
Copy link
Member

wtsnjp commented Jan 20, 2023

Thanks for providing the details of your request and also pointers to the existing project, l3build.

Having a data structure of the command-line options is feasible. It is also possible to support a new option to generate the shell completion script. However, supporting multiple shells such as bash, csh, zsh, fish, and so on can be costly. Choosing one or two shells with a good reason might be difficult. Since most of the tools in TeX Live do not have such a feature, I wonder if only a few TeX Live users will use the feature. I don't want to have that burden directly in this project unless many people request it. Besides, this can be just done outside of this project.

(Hereafter, off-topic for this project)

The zsh completion function that I personally maintain is currently hosted at https://github.com/wtsnjp/texlive-completions.

As a maintainer of Texdoc, I am maintaining the script according to Texdoc updates for the time being, so please do not worry too much about that script will be outdated.

@Freed-Wu
Copy link
Contributor Author

Having a data structure of the command-line options is feasible.

👍

Choosing one or two shells with a good reason might be difficult.

I think it should be: if a shell user wants to support a shell, he will contribute code to this project. Not the maintainers support all shells by themselves. Because:

  1. The maintainers of the project are not possible to be familiar to all shells.
  2. If not any shell user contribute code, it proves the shell don't have enough value to be supported. That is a reason why some shells are supported and why some shells are not supported. (The reason is not difficult at all, really? 😄)

The zsh completion function that I personally maintain is currently hosted

I suggest pushing it to zsh-completions.

@wtsnjp
Copy link
Member

wtsnjp commented Jan 24, 2023

Anyway, I don't have the time and motivation to implement and maintain this feature. I will only review codes if you send pull requests to us. In this case, please make sure to include the corresponding description in the documentation (texdoc.tex and texdoc.1.md) and test cases under the spec directory.

@wtsnjp wtsnjp closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2023
@Freed-Wu
Copy link
Contributor Author

Freed-Wu commented Feb 2, 2023

Is there any project about a data structure of the command-line?

@wtsnjp
Copy link
Member

wtsnjp commented Feb 2, 2023

No, there isn't. You can include that part also to the pull request if you have a plan.

wtsnjp added a commit that referenced this issue Feb 16, 2023
Fix #89, add --print-completion zsh
@wtsnjp wtsnjp closed this as completed Feb 16, 2023
@Freed-Wu
Copy link
Contributor Author

I'm glad to see this completion have been accepted by many Linux distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants