nim-confutils/confutils/defs.nim

62 lines
1.6 KiB
Nim
Raw Normal View History

import
options
2018-11-21 13:25:53 +00:00
type
ConfigurationError* = object of CatchableError
TypedInputFile*[ContentType = Unspecified,
Format = Unspecified,
defaultExt: static string] = distinct string
# InputFile* = TypedInputFile[Unspecified, Unspecified, ""]
# TODO temporary work-around, see parseCmdArg
InputFile* = distinct string
InputDir* = distinct string
OutPath* = distinct string
OutDir* = distinct string
OutFile* = distinct string
RestOfCmdLine* = distinct string
SubCommandArgs* = distinct string
Flag* = object
name*: TaintedString
FlagWithValue* = object
name*: TaintedString
value*: TaintedString
FlagWithOptionalValue* = object
name*: TaintedString
value*: Option[TaintedString]
Unspecified* = object
Txt* = object
SomeDistinctString = InputFile|InputDir|OutPath|OutDir|OutFile
template `/`*(dir: InputDir|OutDir, path: string): auto =
string(dir) / path
template `$`*(x: SomeDistinctString): string =
string(x)
2018-11-21 13:25:53 +00:00
template desc*(v: string) {.pragma.}
template name*(v: string) {.pragma.}
template abbr*(v: string) {.pragma.}
2018-11-21 13:25:53 +00:00
template defaultValue*(v: untyped) {.pragma.}
template defaultValueDesc*(v: string) {.pragma.}
2018-12-19 10:52:32 +00:00
template required* {.pragma.}
template command* {.pragma.}
template argument* {.pragma.}
template hidden* {.pragma.}
template inlineConfiguration* {.pragma.}
2018-11-21 13:25:53 +00:00
template implicitlySelectable* {.pragma.}
## This can be applied to a case object discriminator
## to allow the value of the discriminator to be determined
## implicitly when the user specifies any of the sub-options
## that depend on the disciminator value.