Types
CliAddKind = enum caEqual, ## `--key=value` caPlusEqual, ## `--key+=value` caColon, ## `--key:value` caMinusEqual, ## `--key-=value` caNoSep, ## `-kvalue` caCarentEqual, ## `--key^=value` caEqualNone ## `--key=`
- Source Edit
CliErrPolicy = enum ceColorDiagnostics, ceJsonDiagnostics
- Source Edit
CliFail = object argStr*: string case kind*: CliFailKind of cfMultiFail: subFails*: seq[CliFail] of cfNoSuchSelector: selector*: string of cfNoSuchOption: option*: string else: nil jsonMsg*: JsonNode strMsg*: ColoredText
- Source Edit
CliFailKind = enum cfNoSuchOption, cfNoSuchSelector, cfBadCliSyntax, cfBadCliValue, cfMissingValue, cfMultiFail
- Source Edit
CliOpt = object globalPos*: int ## Absolute position in the input sequence of arguments rawStr*: string ## Raw string value of the command (with all dashes etc) kind*: CliOptKind shortDash*: bool keyPath*: seq[string] ## Full path to the key. `--cc.exe=json` has path ## `["cc", "exe"]`, regular `--help` has path ## `["help"]` keySelect*: string ## Selector value used in bracket options - ## `--warn[Init]:on` has `keySelector = "Init"` valStr*: string ## String value of the command addKind*: CliAddKind optKind*: CliOptKind specialKind*: CliSpecialKind
- Source Edit
CliOptKind = enum coFlag, ## `--flag` coDotFlag, ## `--help.json` coBracketFlag, ## `--warn[Relocate]` coOpt, ## `--opt:value` coDotOpt, ## `--clang.exe:/bin/clang10` coBracketOpt, ## `--warn[Noinit]:true` coArgument, coSpecial, coCommand
- Source Edit
CliParseConfig = object shortOpts*: set[char] specialStart*: seq[string] blockedAddKinds*: set[CliAddKind] errPolicy*: set[CliErrPolicy] hasValue*: proc (arg: CliOpt): bool {.noSideEffect.} seqSeparator*: string
- Source Edit
CliSpecialKind = enum cskVerbatimNext, cskStdinAlias
- Source Edit
Consts
coBracketKinds = {coBracketFlag, coBracketOpt}
- Source Edit
coDashedKinds = {coFlag..coBracketOpt}
- Source Edit
coFlagKinds = {coFlag..coBracketFlag}
- Source Edit
coOptionKinds = {coOpt..coBracketOpt}
- Source Edit
defaulCliParseConfig = (shortOpts: {}, specialStart: [], blockedAddKinds: {}, errPolicy: {}, hasValue: (nil, nil), seqSeparator: ",")
- Source Edit
Procs
func canAddValue(opt: CliOpt): bool {....raises: [], tags: [].}
- Source Edit
func classifyCliArg(arg: string; config: CliParseConfig): CliOptKind {. ...raises: [], tags: [].}
- Source Edit
func cliParse(arg: string; res: var float; config: CliParseConfig): Option[ CliFail] {....raises: [], tags: [].}
- Source Edit
func cliParse(arg: string; res: var int; config: CliParseConfig): Option[CliFail] {. ...raises: [], tags: [].}
- Source Edit
func cliParse(arg: string; res: var string; config: CliParseConfig): Option[ CliFail] {....raises: [], tags: [].}
- Source Edit
func cliParse[En: enum](arg: string; res: var En; config: CliParseConfig): Option[ CliFail]
- Source Edit
func cliParse[T](arg: string; res: var seq[T]; config: CliParseConfig): Option[ CliFail]
- Source Edit
func lispRepr(cli: CliOpt): ColoredText {....raises: [ValueError], tags: [].}
- Source Edit
func needsValue(opt: CliOpt): bool {....raises: [], tags: [].}
- Source Edit
func parseArgument(arg: string; config: CliParseConfig): CliOpt {....raises: [], tags: [].}
- Source Edit
func parseCliOpts(args: seq[string]; config: CliParseConfig = CliParseConfig()): tuple[ parsed: seq[CliOpt], failed: seq[CliFail]] {. ...raises: [Exception, UnexpectedKindError], tags: [RootEffect].}
- Source Edit
func parseCommand(arg: string; config: CliParseConfig): CliOpt {....raises: [], tags: [].}
- Source Edit
func parseFlag(arg: string; config: CliParseConfig): CliOpt {....raises: [], tags: [].}
- Source Edit
func parseOpt(arg: string; config: CliParseConfig): CliOpt {....raises: [], tags: [].}
- Source Edit
func parseSpecial(arg: string; config: CliParseConfig): CliOpt {. ...raises: [UnexpectedKindError], tags: [].}
- Source Edit
func splitCliArgs(args: seq[string]; config: CliParseConfig): seq[string] {. ...raises: [], tags: [].}
- Source Edit
func splitFlag(arg: string; config: CliParseConfig): tuple[keyPath: seq[string], keySelector: string, value: string, dashes: string] {....raises: [], tags: [].}
-
- TODO :: Parse gcc/clang-style flags with selectors -Wno-relocate