@@ -15,6 +15,8 @@ The POSIX standard is often cited when designing command line interfaces. Howeve
1515
1616A command MAY accept sub-commands, options, and operands.
1717
18+ ##### Note: This specification is available as a [ formal grammar] ( #formal-grammar ) , or as a [ railroad diagram] ( ./assets/cli-railroad/index.md ) .
19+
1820### Sub-commands
1921
2022- A sub-command is a part of the command that acts as a command by itself. In other words, a sub-command is a recursive command.
@@ -65,23 +67,26 @@ A command MAY accept sub-commands, options, and operands.
6567
6668## Formal Grammar
6769
68- ``` grammar
70+ ``` C
6971Command ::= CmdIdentifier
7072Command ::= CmdIdentifier Operand*
7173Command ::= CmdIdentifier Option* Operand*
72- CmdIdentifier ::= Alphanumeric*
74+ Command ::= CmdIdentifier Command*
75+ Command ::= CmdIdentifier Option* Command*
76+ CmdIdentifier ::= AlphanumericAnd*
7377Option ::= ShortOption | LongOption
7478ShortOption ::= ShortFlagOption | ShortValueOption
7579LongOption ::= LongFlagOption | LongValueOption
7680ShortFlagOption ::= ' -' Alphanumeric
7781ShortValueOption ::= ' -' Alphanumeric OptionValueDelimiter Value
78- LongFlagOption ::= '--' Alphanumeric Alphanumeric *
79- LongValueOption ::= '--' Alphanumeric Alphanumeric * OptionValueDelimiter Value
82+ LongFlagOption ::= ' --' Alphanumeric AlphanumericAnd *
83+ LongValueOption ::= ' --' Alphanumeric AlphanumericAnd * OptionValueDelimiter Value
8084OptionValueDelimiter ::= Space | ' ='
8185Alphanumeric ::= [0 -9a-zA-Z]
86+ AlphanumericAnd ::= [0 -9a-zA-Z-_]
8287Value ::= Char* | ' "' ( Char | Space )* ' "'
8388Char ::= ( UnicodeExceptDoubleQuotes | ' \" ' )
84- Space ::= ( U+0020 )\ *
89+ Space ::= ( U+0020 )*
8590Operand ::= Value
8691```
8792
0 commit comments