-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Help users learn to quote arguments with spaces in their shell #756
Comments
HI there, @mislav and the team. I've been using cli for a while now, and it feels amazing to be honest. Kudos to the team.!. I'd like to take this one up. Incrementing the already mentioned solutions, here is how I'd like to proceed with the same. In command/issue.go :
func listHeader(arguments) string {
...
if (hasFilters) {
return fmt.Sprintf("No %ss match your search in %s. Perhaps you forgot to escape the spaces ? ", itemName, repoName)
}
...
}
var issueListCmd = &cobra.Command{
Use: "list",
Short: "List and filter issues in this repository",
Long: `This commands lets you list issues according to the labels that you have passed
Remember to escape whitespaces or mention the whitespace separated issue names within quotations in your terminal to help identify cli the correctly named issue.
Usage Example:-
gh issue list -l help\ wanted
gh issue list -l "help wanted"
`
RunE: issueList,
} Any more things that need to be added ? Please let me know. Thanks. |
Yay, thanks for offering to help!
|
It seems to me that we can have a custom validator that provides the error message that we need to give. What I mean is- var issueListCmd = &cobra.Command{
---
Args: func (cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return fmt.Errorf("unknown command %q for %q. Please include quotes if necessary", args[0], cmd.CommandPath())
}
return nil
}
---
} We can just write what we need. So that should be a bit easy now.
Sure thing. Can update as needed. |
Looking forward to the pull request! ✨ |
Running this in a shell such as bash or zsh will not produce the sometimes-expected result of looking up issues under the
help wanted
label:This is because the value
help wanted
should be quoted or escaped in one's shell to ensure that it's passed as a single value to--label
, rather than as two distinct argumentshelp
+wanted
(where the latter wouldn't be interpreted as relating to--label
at all):This isn't a bug with CLI, but is a common pitfall for shell-users in general that we could ideally help our users detect and recover from. Possible approaches:
gh help issue list
docsgh issue list
("wanted"
in the above example) and present an error such as “unrecognized argument 'wanted': did you forget to quote values with spaces?”Originally reported by @tierninho
Loosely related issues that stem as consequence of shell behavior (as opposed to being bugs in
gh
): #223 #595 #315The text was updated successfully, but these errors were encountered: