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

Fish tab completions #763

Merged
merged 6 commits into from
Jan 4, 2019
Merged

Fish tab completions #763

merged 6 commits into from
Jan 4, 2019

Conversation

John-Goff
Copy link
Contributor

#758

I tried to copy the zsh and bash completions as closely as I could, but I'd appreciate if someone else could review these. Preferably someone who's more familiar with how the bash and zsh completions should preform than I am!

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@John-Goff thanks for adding fish shell support. These completions look great. I left a couple of suggestions for you.

In the meantime, I’ll pull this down and give it a try.

### Fish

Completions must go in the user defined `$fish_complete_path`. By default, this is `~/.config/fish/completions`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency could we keep the bundle completion file named exercism_completion.fish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that, but the final file has to have the same name as the executable. I figured it would be easier to have it named that way from the start, rather than requiring users to rename it themselves. I foresee at least a few people dragging and dropping rather than using the command line.

# Download
complete -f -c exercism -n "__fish_use_subcommand" -a "download" -d "Downloads and saves a specified submission into the local system"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s e -l exercise -d "the exercise slug"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s h -l help -d "help for download"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably do without tab completion for the help flag, as it will repeat the information you have already added for each option. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these completions fire when a user types exercism <command> -<tab> (note the dash). It's only there for completeness, I created these mostly by copying the output of exercism help <command>.


# Help
complete -f -c exercism -n "__fish_use_subcommand" -a "help" -d "Shows a list of commands or help for one command"
complete -f -c exercism -n "__fish_seen_subcommand_from help" -a "configure download help open submit troubleshoot upgrade version workspace"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fire after typing exercism help, it's useful to be able to tab through the list of commands you can run help on.

@John-Goff
Copy link
Contributor Author

Has anyone been able to test these? If I need to make any changes, please let me know.

@nywilken
Copy link
Contributor

nywilken commented Dec 6, 2018

Has anyone been able to test these? If I need to make any changes, please let me know.

@John-Goff I had an opportunity to test the first time around, but didn't test entirely. I will take another look. Thank you for the detailed responses.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@John-Goff sorry for the long review time. It has been a busy last few months for me. I hope you are still with us and interested in pushing this forward. I tested the completions and things work as expected - the Fish Shell is alright.

I left a comment regarding the sequence completion for the timeout flag. Otherwise this is looks good to me. Thanks!


# Options
complete -f -c exercism -s h -l help -d "show help"
complete -f -c exercism -l timeout -a "(seq 0 100 100000)" -d "override default HTTP timeout"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tab completion for possible timeout values is cool. But I found the possible options a bit overwhelming - it filled my terminal. Is this a common practice you’ve seen in fish? If so, I recommend shortening the possible value range.

Removing the range entirely has a funky behavior where if I tab after the timeout flag it tab completes to some random file. Possibly why you added the sequence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can definitely shorten the range. I agree there's potentially too many options to tab through. Your analysis is spot on, I added it to prevent the files autocompleting there. Files autocompleting is fish's default behaviour, and most programs do this if there's no available options to add. I thought some range of numbers to be better than nothing, if for no other reason than to show that it's possible. I'll shorten the range.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible in fish to document a value as it is in zsh? If so wouldn't it make sense to only have most commonly used timouts of 10, 30, 60 seconds, 5 and 10 minutes?

In zsh such a completion list would roughly look like:

10 -- 10 seconds
30 -- 30 seconds
60 -- 1 minute
300 -- 5 minutes
600 -- 10 minutes

I consider such a completion much better than a plain list of values that no-one knows what they do without canceling the completion and looking them up in the documentation first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed possible and I have updated the completions to include this. Thanks for the suggestion, I was really unsure what to put for timeout values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fish this looks like

➤ exercism --timeout=
…-timeout=10  (10 seconds)  …-timeout=30  (30 seconds)  …-timeout=60  (1 minute)  …-timeout=300  (5 minutes)  …-timeout=600  (10 minutes)

@John-Goff
Copy link
Contributor Author

@nywilken No problem and thanks for your review!

@NobbZ
Copy link
Member

NobbZ commented Dec 20, 2018

I've left another comment on the timeout range inline.

@John-Goff
Copy link
Contributor Author

Apologies I didn't see this update before now. Thank you for your review, I have updated the completions to incorporate your suggestions.

@kytrinyx
Copy link
Member

kytrinyx commented Jan 4, 2019

Thank you @John-Goff! I'm going to pull this in, and if we find any other improvements we can do them in a second round ✨

@kytrinyx kytrinyx merged commit c5c202e into exercism:master Jan 4, 2019
@John-Goff John-Goff deleted the fish-completions branch January 5, 2019 19:32
@hellow554
Copy link

@John-Goff please use one of the github keywords to automatically close a referenced issue when the PR has been merged so it's easier :) thanks for the work!

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

Successfully merging this pull request may close these issues.

5 participants