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

Shell completion #946

Merged
merged 25 commits into from Jan 24, 2019
Merged

Conversation

schoettl
Copy link
Collaborator

Related to #945

Comments?

Please don't merge yet, I want to enhance the completion behavior with --files=.

@simonmichael simonmichael changed the title Shell completion Shell completion (WIP) Jan 12, 2019
@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. cli Command line parsing, options, arguments and suchlike. labels Jan 12, 2019
@schoettl
Copy link
Collaborator Author

Completion for Bash is finished, I think!

I can only provide completion for Bash. Scripts for other Shells (e.g. Fish, zsh) are welcome. I'll add a section in the README on how to use this "framework".

@simonmichael
Copy link
Owner

Nice @schoettl. I just added the (WIP) suffix to remind me not to merge, feel free to remove it now (I'd like to know if you have that access).

Would anyone like to do a little testing before I merge this ?

hledger-completion.bash does not depend on command-options because this
phony target is so slow. Use  make  once and subsequently only
make hledger-completion.bash
@schoettl schoettl changed the title Shell completion (WIP) Shell completion Jan 12, 2019
It seems to be convention to start the completion function name with an
underscore. I also prepend an underscore to the global variable.

(I still don't understand why  env  does not show this global variable
defined in the hledger-completion.bash script.)
@schoettl schoettl changed the title Shell completion Shell completion (WIP) Jan 12, 2019
@schoettl
Copy link
Collaborator Author

Another bugfix for filename completion. I think, now it's functioning really good!

Some testers? ... before I remove the WIP in the title...

I'm not completely satisfied with it because I'm not sure if I fully understand Bash's completion system (complete, compgen, compopt).

@schoettl
Copy link
Collaborator Author

I added completions for query filters like "status:" or "inacct:" in addition to account names.

Filters are taken from http://hledger.org/doc/1.1/manual.html#queries

@simonmichael
Copy link
Owner

Nice. Why version 1.1 ? You probably want to follow http://hledger.org/manual.html#queries

Let me know when you feel ready to have this merged.

@schoettl
Copy link
Collaborator Author

Oh, the search engine took me to the old doc. Fixed.

I also added amt:<=, status:!, and so on – these are not useful for completion but as documentation when the user presses tab twice to show possible completions. The disadvantage is that the number of suggestions is getting unwieldy. But it might be useful.

I'd like to wait a few more days before the merger. Maybe I come up with more ideas :)

@schoettl
Copy link
Collaborator Author

TODO for me: install current latest version (AUR, *-git?) of hledger and run make again to get latest option and command completions.

@schoettl schoettl changed the title Shell completion (WIP) Shell completion Jan 23, 2019
@schoettl
Copy link
Collaborator Author

Ready to merge.

@simonmichael
Copy link
Owner

This creates the shell-completions/ subdirectory, which contains a README for getting started. So far so good. How can we make this more discoverable and get folks likely to use it, using it ? Where could we mention it in the docs ?

@simonmichael
Copy link
Owner

Perhaps a new page in the Cookbook, & linked in the wiki sidebar ?

@simonmichael
Copy link
Owner

And/or.. a new section in the hledger manual ?

@schoettl
Copy link
Collaborator Author

I'd rather try to get package maintainers to install it together with hledger. Then, people who use auto completion will quickly find out. (Do we have a changelog?)

I'm not sure if it's worth a section in the hledger man page. I'm not aware of other programs that have a description of their shell completion in the man page.

A cookbook entry would be useful if the completion is not installed with the package manager. If it is installed automatically, I would just reference to the README to not duplicate content that is only relevant for developers. What do you think?

@simonmichael
Copy link
Owner

I think it's hard/slow to get new users; I would advertise everywhere that makes sense. And I would guess many/most hledger users aren't installing via system package. For myself trying this out, I'd like to follow some kind of link from the docs accessible from http://hledger.org . But I'm going to merge the work so far, and we can follow up. Thanks for working on it!

@simonmichael simonmichael merged commit 0025367 into simonmichael:master Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. cli Command line parsing, options, arguments and suchlike.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants