Skip to content

Implement shell completion for +group and ~group - #1842

Merged
Jasha10 merged 8 commits into
hydra-ecosystem:mainfrom
Jasha10:closes1841
Oct 9, 2021
Merged

Jasha10 merged 8 commits into
hydra-ecosystem:mainfrom
Jasha10:closes1841

Conversation

@Jasha10

@Jasha10 Jasha10 commented Oct 2, 2021 •

Copy link
Copy Markdown
Contributor

This PR adds logic Hydra's shell-completion, handling the cases of '+group' and '~group'.
Closes #1841.

Completions enabled by this PR:

  • +gro -> +group= (just like if no plus is given)
  • +group= -> +group=option (just like if no plus is given)
  • + -> +group=
  • ~gro -> ~group (note no trailing equal sign)
  • ~group= -> ~group=option (just like if no tilde is given)
  • ~ -> ~group

Edit:
I was not able to get the tilde completions ('~group...') working with fish or zsh; those shells have special completion logic for words starting with tilde.

@Jasha10
Jasha10 requested review from jieru-hu and pixelb October 2, 2021 13:39
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 2, 2021
@Jasha10

Jasha10 commented Oct 2, 2021 •

Copy link
Copy Markdown
Contributor Author

It seems that CI is failing because zsh is treating the tilde character '~' in a special way.

Edit: seems related to zsh's filename expansion feature. I'm not sure how to get zsh to pass the tilde character through to hydra...

@Jasha10
Jasha10 marked this pull request as draft October 2, 2021 14:27
@Jasha10
Jasha10 removed request for jieru-hu and pixelb October 2, 2021 14:28
@Jasha10
Jasha10 marked this pull request as ready for review October 2, 2021 22:53
@Jasha10
Jasha10 requested review from jieru-hu and pixelb October 2, 2021 22:54

@pixelb pixelb left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see bash and zsh are different wrt ~ expansion.

bash will fall back to treating ~blah as literal if there is no blah user,
while zsh will give an error.

I.e. bash could start giving errors if there was a ~hydra or ~group user on the system.

I wonder would the most general fix be to quote the ~,
i.e. with \~hydra etc. in the tests to avoid this issue.

One is generally going to need to quote tilde while on the command line anyway.

@omry

omry commented Oct 4, 2021 •

Copy link
Copy Markdown
Collaborator

One is generally going to need to quote tilde while on the command line anyway.

For bash at least, I never had to quote ~ (As you are saying, it might conflict in the rare case that there is a user matching the config group name.
if zsh is more strict about it we can just exclude it from the test.

I wonder would the most general fix be to quote the ~,
i.e. with ~hydra etc. in the tests to avoid this issue.

Worth a try:

$ echo ~omry
/Users/omry
$ echo \~omry
~omry

@pixelb pixelb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is fine in isolation.

The test adjustments can be done separately

@Jasha10
Jasha10 merged commit f797ead into hydra-ecosystem:main Oct 9, 2021
@Jasha10
Jasha10 deleted the closes1841 branch October 9, 2021 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvements to shell completion

4 participants