Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions commandeer.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import algorithm
import parseopt2
import parseopt
import sequtils
import strutils
import tables
Expand Down Expand Up @@ -51,7 +51,7 @@ proc getOptionAssigner(s: Subcommand, key: string): Assigner =
var errorMessage: string = ""
var currentSubcommand = newSubcommand()
var subCommands = newTable[string, Subcommand]()
var cliTokens: seq[GetoptResult]
var cliTokens: seq[tuple[kind: CmdLineKind, key: string, val: string]]
var inSubcommand = false

## Debugging procs ##
Expand Down Expand Up @@ -122,7 +122,7 @@ type
CmdTokenKind {.pure.} = enum
argument, option, subcommand, empty
CmdToken = tuple
getOptResult: GetoptResult
getOptResult: tuple[kind: CmdLineKind, key: string, val: string]
kind: CmdTokenKind


Expand All @@ -142,7 +142,7 @@ proc obtainCmdToken(consume: bool): CmdToken =
let cliToken = if consume: cliTokens.pop() else: cliTokens[^1]
if not inSubcommand and currentSubcommand.index == 0 and cliToken.key in subcommands:
return (getOptResult: cliToken, kind: CmdTokenKind.subcommand)
elif cliToken.kind in [parseopt2.cmdLongOption, parseopt2.cmdShortOption]:
elif cliToken.kind in [parseopt.cmdLongOption, parseopt.cmdShortOption]:
return (getOptResult: cliToken, kind: CmdTokenKind.option)
else:
return (getOptResult: cliToken, kind: CmdTokenKind.argument)
Expand Down Expand Up @@ -345,6 +345,6 @@ template subcommand*(identifier: untyped, subcommandNames: varargs[string],
subCommands[subcommandName] = thisSubcommand

template commandline*(statements: untyped): untyped =
cliTokens = reversed(toSeq(parseopt2.getopt()))
cliTokens = reversed(toSeq(parseopt.getopt()))
statements
interpretCli()
2 changes: 1 addition & 1 deletion commandeer.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.12.3"
version = "0.12.4"
author = "Guillaume Viger"
description = "A small command line parsing DSL"
license = "MIT"
Expand Down