Arguments

Todo

Naming convention

  • Basic classes → Argument

  • Named arguments → Flag

  • Character prefixes → Short, Long, Windows

Overview

graph LR; CLA[CommandLineArgument] style CLA stroke-dasharray: 5 5 EA[ExecutableArgument] NA[NamedArgument] style NA stroke-dasharray: 5 5 VA[ValuedArgument] style VA stroke-dasharray: 5 5 NVA[NamedAndValuedArgument] style NVA stroke-dasharray: 5 5 BF[BooleanFlag] style NVA stroke-dasharray: 5 5 NTA[NamedTupledArgument] style NTA stroke-dasharray: 5 5 NKVPA[NamedKeyValuePairsArgument] style NKVPA stroke-dasharray: 5 5 CLA ----> EA CLA --> NA CLA --> VA NA --> NVA VA --> NVA NA --> BF VA --> BF NA --> NTA VA --> NTA NA --> NKVPA VA --> NKVPA CA["<b>CommandArgument</b><br/><div style='font-family: monospace'>command</div>"] FA[FlagArgument] style FA stroke-dasharray: 5 5 NA ---> CA NA ---> FA SA["<b>StringArgument</b><br/><div style='font-family: monospace'>value</div>"] SLA["<b>StringListArgument</b><br/><div style='font-family: monospace'>value1 value2</div>"] PA["<b>PathArgument</b><br/><div style='font-family: monospace'>file1.txt</div>"] PLA["<b>PathListArgument</b><br/><div style='font-family: monospace'>file1.txt file2.txt</div>"] VA ---> SA VA ---> SLA VA ---> PA VA ---> PLA NVFA["<b>NamedAndValuedFlagArgument</b><br/><div style='font-family: monospace'>output=file.txt</div>"] style NVFA stroke-dasharray: 5 5 NOVFA["<b>NamedAndOptionalValuedFlagArgument</b><br/><div style='font-family: monospace'>output=file.txt</div>"] style NOVFA stroke-dasharray: 5 5 NVA --> NVFA NVA --> NOVFA

Without Prefix Character(s)

RAW Format

Examples

Argument Class

executable

prog

ExecutableArgument

--

prog -option -- file1.txt

DelimiterArgument

command

prog help

CommandArgument

string

prog value

StringArgument

string1 string2

prog value1 value2

StringListArgument

path

prog file1.txt

PathArgument

path1 path2

prog File1.log File1.log

PathListArgument

Executable

An executable argument represents a program/executable. The internal value is a Path object.

Command

Commands are (usually) mutually exclusive arguments and the first argument in a list of arguments to a program. They are used to logically group arguments.

While commands can or cannot have prefix characters, they shouldn’t be confused with flag arguments or string arguments.

Example:

  • prog command -arg1 --argument2

See also

String

A simple argument accepting any string value. If a string has a predefined format, more specific argument classes should be used like Command, Flag or PathArgument.

See also

List of Strings

Like StringArgument but supporting a list of strings.

See also

Path

An argument accepting a Path object.

List of Paths

Like PathArgument but supporting a list of paths.

With Prefix Character(s)

Commonly used prefix characters are: single and double dash, single slash, or plus character(s).

Single Dash Argument Format

Double Dash Argument Format

Single Slash Argument Format

Argument Class

-command

--command

/command

ShortCommand
LongCommand
WindowsCommand

-flag

--flag

/flag

ShortFlag
LongFlag
WindowsFlag

-flag
-no-flag

--flag
--no-flag

/flag
/no-flag

ShortBooleanFlag
LongBooleanFlag
WindowsBooleanFlag

-flag
-flag=value

--flag
--flag=value

/flag
/flag=value

ShortOptionalValuedFlag
LongOptionalValuedFlag
WindowsOptionalValuedFlag

-flag=value

--flag=value

/flag=value

ShortValuedFlag
LongValuedFlag
WindowsValuedFlag

-flag=value1 -flag=value2

--flag=value1 --flag=value2

/flag=value1 /flag=value2

ShortValuedFlagList
LongValuedFlagList
WindowsValuedFlagList

-flag value

--flag value

/flag value

ShortTupleFlag
LongTupleFlag
WindowsTupleFlag

-gKey1=value1 -gKey2=value2

--gKey1=value1 --gKey2=value2

/g:Key1=value1 /g:Key2=value2

ShortKeyValueFlag
LongKeyValueFlag
WindowsKeyValueFlag

Command

Todo

Write documentation.

graph LR; CLA[CommandLineArgument] style CLA stroke-dasharray: 5 5 CLA --> NA[NamedArgument] style NA stroke-dasharray: 5 5 NA --> CA["<b>CommandArgument</b><br/><div style='font-family: monospace'>command</div>"]; CA --> SCA["<b>ShortCommand</b><br/><div style='font-family: monospace'>-command</div>"]; CA --> LCA["<b>LongCommand</b><br/><div style='font-family: monospace'>--command</div>"]; CA --> WCA["<b>WindowsCommand</b><br/><div style='font-family: monospace'>/command</div>"];

Flag

A flag is a command line argument that is either present or not. If present that argument is said to be activated or true.

3 variants are predefined with prefixes -, -- and /.

Variants

graph LR; CLA[CommandLineArgument] style CLA stroke-dasharray: 5 5 CLA --> NA[NamedArgument] style NA stroke-dasharray: 5 5 NA --> FA[FlagArgument] style FA stroke-dasharray: 5 5 FA --> SFA["<b>ShortFlag</b><br/><div style='font-family: monospace'>-flag</div>"] FA --> LFA["<b>LongFlag</b><br/><div style='font-family: monospace'>--flag</div>"] FA --> WFA["<b>WindowsFlag</b><br/><div style='font-family: monospace'>/flag</div>"]

Flag with Value

Todo

Write documentation.

Boolean Flag

Todo

Write documentation.

Flag with Optional Value

Todo

Write documentation.

List of Flags with Value

Todo

Write documentation.

Flag with Value as a Tuple

Todo

Write documentation.