Repository navigation
Inconsistent use of curly braces and square brackets for command args syntax e.g. {args} and [args] respectively #10432
Description
Activity
Hey @iamazeem,
Our Primer Style Guidelines go into some detail on the different formats.
The gist is that:
- Placeholders the user must replace are delimited by angled brackets
gh pr view <issue-number> - Optional arguments are delimited by square brackets
gh pr checkout [--web] - Optional mutually exclusive arguments are delimited by square brackets and separated by pipes
gh pr view [<number> | <url>] - Required mutually exclusive arguments are delimited by curly braces and separated by pipes
gh pr {view | create}
From your output the only obviously incorrect example is:
38: Use: "rename {<id> | <url>} <oldFilename> <newFilename>",Where variable names are expected to be kebab cased e.g.
rename {<id> | <url>} <old-filename> <new-filename>.Are there any other examples you've spotted that violate the guidelines?
- Placeholders the user must replace are delimited by angled brackets
- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on Feb 13, 2025 Hey @williammartin,
Thank you for your detailed comment! 👍
Found these cases violating Variable naming along with
rename(as you pointed out above):pkg/cmd/repo/license/view/view.go: 37: Use: "view {<license-key> | <SPDX-ID>}",pkg/cmd/browse/browse.go: 72: Use: "browse [<number> | <path> | <commit-SHA>]",The rest looks fine according to the guidelines.
I'll open dedicated issues if I notice anything.Those are interesting cases since they are actually acronyms and maybe the casing isn't so bad.
However, I think we should just make them lower case anyway.
Acceptance Criteria
When I run
gh repo license view --help
Then The usage uses lower-kebab-caseWhen I run
gh browser --help
Then The usage uses lower-kebab-caseWhen I run
gh gist rename --help
Then The usage uses lower-kebab-caseReacted by Azeem- addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetichelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Feb 14, 2025 @williammartin: AC looks good. 👍
Just a typo:browser=>browse
Describe the bug
As mentioned in the title, the command args syntax is inconsistent.
Affected version
Steps to reproduce the behavior
Use:\s+".* \{.*\}.*"to find occurrences with curly bracesHere's a list of such occurrences from VSCode:
The majority of the commands are using square brackets syntax:
Use:\s+".* \{.*\}.*") (20 results)Use:\s+".* \[.*\].*") (75 results)Expected vs actual behavior
The syntax should be consistent.
Logs
N/A