cli: Clarify error message when someone uses # instead of  for pr and issue commands  
 Describe the feature or problem you’d like to solve
GitHub issues and prs are prefixed with a “#” character. gh issue list and gh pr list commands display them as such:
Issues for ORG/REPO
#1234  [Bug] Red X on dialog box                                 (Bug, GUI, Linux, …)
#2345  [Bug] NullReferenceException encountered during downl...  (Bug, ConsoleUI)
But if you try to view one of these issues using the key as listed:
$ gh issue view #1234
issue required as argument
Proposed solution
If the parameter following a view command starts with a “#” character, attempt to parse the remainder of the string as a number before reporting failure.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 19 (16 by maintainers)
Given how shells interpret # we don’t plan to support this. That said, I’m thinking we can start leaving the # off of the output of list/status output commands to make copy-pasting easier? Curious if folks have thoughts on that.
We are generally in favor of better error messages. However, if someone writes (or pastes)
gh issue view #123, since the#...portion is completely stripped by their shell we cannot know at execution time that there was an argument to start with. Therefore,gh issue view #123is functionally equivalent togh issue view, and we cannot improve the error message in this case.@mislav I think if you do that, people using
zshwill write tutorials or share commands that mysteriously fail when Bash users try them. 😬@mislav You can still improve the error message without knowing that they typed a hash-prefixed issue number.
Scenario A
gh issue viewgh“sees”gh issue viewghtells them that an issue argument is expected, as well as the expected format (issue integer or issue URL).Scenario B
gh issue view #123gh“sees”gh issue viewghtells them that an issue argument is expected, as well as the expected format (issue integer or issue URL).I think that the info about the expected format is useful regardless of whether they omitted the argument or their shell stripped the argument.
Also note that the hash is not universally stripped. I’m using iTerm2 and zsh in macOS Catalina, and
ghabsolutely sees the#123:Scenario C
gh issue view #123gh“sees”gh issue view #123ghtells them that an issue argument is expected, as well as the expected format (issue integer or issue URL).It would be a small thing that, instead of vaguely telling people their input was incorrect, guides them towards making their input correct.
@markjaquith thanks for your input, and I totally agree with how you framed this!
Let’s leave the
#123syntax, and make the error message clearer 👍It would make copy-pasting into the CLI easier, but I think it sacrifices some clarity when listing Issues.
#123is how GH displays Issues. That’s very clearly a GitHub Issue. Also, copy-pasting into an Issue or a comment SHOULD contain the#. I don’t think it’s a clear win.It might help if the error message gave you more info about the expected
gh issue view 123usage. When I saw “issue required as argument” I was like “but I GAVE IT TO YOU as an argument!”It wasn’t immediately clear that it was the integer only that was expected.