-
Notifications
You must be signed in to change notification settings - Fork 349
Improve zsh completion script generation #727
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
Conversation
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this awesome work, @rgoldberg! From testing it looks flawless, just have a few minor notes/questions below.
Sources/ArgumentParser/Completions/ZshCompletionsGenerator.swift
Outdated
Show resolved
Hide resolved
@natecook1000 Thanks for the feedback. Do you want me to update things via new commits, or by fixing existing commits & force pushing? I assume the former, since it seems like SAP squashes PRs, but I wanted to check with you first. I will push new commits with fixes so I can resolve conversations here with code having been submitted. If you want me to redo existing commits then force push to keep the PR commit history cleaner, let me know; if so, I'll move the changes from the new commits to the original commits, then force push. |
@natecook1000 I've submitted fixes in new commits for the conversations that I've resolved. Waiting for your instructions on the open conversations. Thanks for all the feedback & help. |
f484794
to
e0f8ed0
Compare
Rebased on the new |
e0f8ed0
to
937977a
Compare
Feel free to handle commits/updating however's most comfortable for you – we'll squash on merge, so the in-process commits aren't terribly important. |
Simplify zsh indent generation. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Brace & quote parameter uses. Use [@] for quoted array output. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
4 consecutive single quotes were obviously intended to be 2 escaped single quotes, but that isn't zsh syntax. Use 2 double quotes instead. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Remove trailing spaces from InstallingCompletionScripts.md. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
If someone already escapes single quotes from the String, this will cause an issue, but no one should be required to go to the trouble to manually escape single quotes in their script, especially since the requirement isn't documented or normal. Signed-off-by: Ross Goldberg <[email protected]>
If a Swift custom completion function returns an empty [String], if the user tries to complete it, refuse to complete instead of inserting a blank space into the command line. If a Swift custom completion function returns a [String] including a Swift empty String or including a String with a description but with a blank completion (e.g., ":description"), if that completion is selected, complete to a zsh empty string '' instead of inserting a blank space into the command line. Disambiguating between an empty [String] & a [String] with one empty String element requires that an extra value be appended to the output of the Swift custom function, which is then removed by the completion script. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Disable history ! in zsh completion scripts. Signed-off-by: Ross Goldberg <[email protected]>
…ift. Signed-off-by: Ross Goldberg <[email protected]>
…nsion. Signed-off-by: Ross Goldberg <[email protected]>
Move from ArgumentDefinition extension to [ParsableCommand.Type] extension. Signed-off-by: Ross Goldberg <[email protected]>
…ells. Signed-off-by: Ross Goldberg <[email protected]>
Function names are globally scoped. Without namespacing, if 2 programs use different versions of Swift Argument Parser, one could overwrite the other's different version of the same helper function. Renamed functions from *_completion to *_complete, as they complete, not return a completion. Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Allows list completions to contain spaces. Resolve apple#726 Signed-off-by: Ross Goldberg <[email protected]>
Signed-off-by: Ross Goldberg <[email protected]>
Redid a comment as a DocC. Signed-off-by: Ross Goldberg <[email protected]>
Document why & how this pseudo-completion is used. Do not trim whitespace in testing, as that breaks with the space pseudo-completion. Testing should be as exact as possible; trimming whitespace makes it less exact. Signed-off-by: Ross Goldberg <[email protected]>
…commands. Force unwrap first in ZshCompletionsGenerator.swift. Signed-off-by: Ross Goldberg <[email protected]>
937977a
to
6d32ef3
Compare
@natecook1000 I've finished all the fixes. Please note that I cannot move the members from the I've also rebased on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look great! Just a little bit of cleanup, then we're good to merge 🎉
Tests/ArgumentParserGenerateDoccReferenceTests/Snapshots/testColorDoccReference().md
Show resolved
Hide resolved
@natecook1000 Just replied to your 2 comments. |
Improve zsh completion script generation.
There are many issues with script generation. Some of them are documented in #679 & its comments.
This PR is for a first batch of zsh completion script fixes.
Each commit should note the fix(es) that it contains.
If you want documentation of the fixes directly in the GitHub issue #726 and/or in this PR without having to look at the commit messages, I can include info from the commit messages here and/or in the issue description.
If you want the this PR split up, parts removed or changed, etc., please let me know, and I'll make the requisite changes.
After this PR is merged, I will sequentially create an issue & submit a PR each for initial bash & fish fixes, then one or more PRs for cross-shell changes, then I will resume working on more fixes.
Resolve #726
Checklist