Skip to content

Commit fe49c2d

Browse files
Merge pull request cli#862 from cli/cli-syntax
Add command line syntax doc
2 parents a7cef60 + a46e7ca commit fe49c2d

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

docs/command-line-syntax.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# How we document our command line syntax
2+
3+
## Literal text
4+
5+
Use plain text for parts of the command that cannot be changed
6+
7+
_example:_
8+
`gh help`
9+
The argument help is required in this command
10+
11+
## Placeholder values
12+
13+
Use angled brackets to represent a value the user must replace. No other expressions can be contained within the angeled brackets.
14+
15+
_example:_
16+
`gh pr view <issue-number>`
17+
Replace `<issue-number>` with an issue number
18+
19+
## Optional arguments
20+
21+
Place optional arguments in square brackets. Mutually exclusive arguments can be included inside square brackets if they are separated with vertical bars.
22+
23+
_example:_
24+
`gh pr checkout [--web]`
25+
The argument `--web` is optional.
26+
27+
`gh pr view [<number> | <url>]`
28+
The `<number>` and `<url>` arguments are optional.
29+
30+
## Required mutually exclusive arguments
31+
32+
Place required mutually exclusive arguments inside braces, separate arguments with vertical bars.
33+
34+
_example:_
35+
`gh pr {view | create}`
36+
37+
## Repeatable arguments
38+
39+
Ellipsis represent arguments that can appear multiple times
40+
41+
_example:_
42+
`gh pr close <pr-number>...`
43+
44+
## Variable naming
45+
46+
For multi-word variables use dash-case (all lower case with words separated by dashes)
47+
48+
_example:_
49+
`gh pr checkout <issue-number>`
50+
51+
## Additional examples
52+
53+
_optional argument with placeholder:_
54+
`command sub-command [<arg>]`
55+
56+
_required argument with mutually exclusive options:_
57+
`command sub-command {<path> | <string> | literal}`
58+
59+
_optional argument with mutually exclusive options:_
60+
`command sub-command [<path> | <string>]`

0 commit comments

Comments
 (0)