-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax Description
A command line as understood by Argum can contain:
- Any number of Options
- Any number of Positional Arguments or simply Positionals
- An optional single Option Terminator. If an Option Terminator occurs everything following it is considered a Positional.
In BNF notation
CommandLine := *(*Option *Positional) [OptionTerminator *AnyArgument]
An Option can be of one of the three types described below. All option types allow a single optional Argument to be given with them.
A standalone short option starts with one of the defined short option prefixes followed by a single letter. By default the only short option prefix is -
but that can be changed. If no short option prefixes are configured the short options aren't recognized.
Thus -a
is a short option and so is -c
. However -foo
isn't (more than one letter) and so isn't --c
(wrong prefix).
A short option can have an argument either as a separate command line argument either:
- directly following it:
-c arg
or - attached to it:
-carg
. In both cases the Argument isarg
.
Multiple consequent short options can be concatenated together with one prefix. For example if -c
and -a
are both short options they can be specified:
- separately as
-c -a
or - merged as
-ca
If short options are merged only the last one of the merged sequence can have an argument. Both
-
-ca arg
and -
-caarg
mean option-c
followed by-a
with an argumentarg
A multi-short option starts with one of the defined short option prefixes followed by more than one letter. By default the only short option prefix is -
but that can be changed. If no short option prefixes are configured the multi-short options aren't recognized.
Thus -foo
is a multi-short option and so is -bar
.
By default, multi-short options can be abbreviated so if a -foo
option is defined, -fo
and -f
will be recognized as -foo
as well. Such abbreviation can be disabled.
Due to definitions above various ambiguities can arise. For example if -bar
, -baz
and -b
are all defined then -ba
is potentially ambiguous and so is -b
. Moreover if -a
and -r
are also defined in addition to those then does -bar
mean -bar
or merged -b
, -a
and -r
? Argum resolves any ambiguities in the following manner:
- Home
-
Usage Guide
Basics
Error Handling
Thread Safety
Adding Help
Defining options
Positional arguments
Reporting errors from handlers
Parsing common data types
Validation
Depending on order
Subcommands
Response files
Partial Parsing -
Advanced
Syntax Description
Customizing syntax
Customizing usage and help
Localization