parseopt
nimony/lib/std/parseopt.nim
proc paramStr(i: int64): stringproc paramCount(): int64type CmdLineKind = enum cmdEnd = (0, "cmdEnd") cmdArgument = (1, "cmdArgument") cmdLongOption = (2, "cmdLongOption") cmdShortOption = (3, "cmdShortOption")
func dollar`.CmdLineKind(e: CmdLineKind): stringtype OptParser = object pos: int64 inShortState: bool idx: int64 kind: CmdLineKind key: string val: string current: string cmdLine: seq useCmdLine: bool
func initOptParser(): OptParserfunc initOptParser(cmdLine: sink seq): OptParserParse the explicit
cmdLineinstead of the process arguments. Useful for re-parsing options collected from a.argsfile. WhencmdLineis empty, falls back to the process argv (matches Nim'sstd/parseopt).proc next(p: var OptParser)iterator getopt(): tuple[CmdLineKind, string, string]iterator getopt(p: var OptParser): tuple[CmdLineKind, string, string]Iterate over an already constructed parser. Nim's
std/parseopthas this overload and code written against it (var p = initOptParser(args)followed byfor kind, key, val in getopt(p)) is the common shape, so it must exist here too.{.sideEffect.}becausenextreads the process argv whenever the parser was not given an explicit command line.iterator getopt(cmdLine: sink seq): tuple[CmdLineKind, string, string]Same as the no-argument
getopt, but parsescmdLineinstead of the process argv. Useful for re-parsing options collected from an.argsfile (e.g.nimony.args).