diff options
author | Araq <rumpf_a@web.de> | 2019-05-24 09:43:04 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-05-24 09:43:04 +0200 |
commit | cacd6d1070b79a820bd77e757d1e70c02730c90e (patch) | |
tree | cb691442523cc05751d303a783e5a5afd89e8a87 | |
parent | 39a3dbb16b238572d43b1ceecbb03036811e0e47 (diff) | |
download | Nim-cacd6d1070b79a820bd77e757d1e70c02730c90e.tar.gz |
fixes #11294
-rw-r--r-- | compiler/commands.nim | 4 | ||||
-rw-r--r-- | lib/pure/parseopt.nim | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index 4a88137b9..994442af0 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -106,7 +106,7 @@ proc writeCommandLineUsage*(conf: ConfigRef) = msgWriteln(conf, getCommandLineDesc(conf), {msgStdout}) proc addPrefix(switch: string): string = - if len(switch) == 1: result = "-" & switch + if len(switch) <= 1: result = "-" & switch else: result = "--" & switch const @@ -770,6 +770,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; processOnOffSwitchG(conf, {optDocInternal}, arg, pass, info) of "multimethods": processOnOffSwitchG(conf, {optMultiMethods}, arg, pass, info) + of "": + conf.projectName = "-" else: if strutils.find(switch, '.') >= 0: options.setConfigVar(conf, switch, arg) else: invalidCmdLineOption(conf, pass, switch, info) diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index 0f8f8197c..baa46c65a 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -274,8 +274,9 @@ when declared(os.paramCount): proc handleShortOption(p: var OptParser; cmd: string) = var i = p.pos p.kind = cmdShortOption - add(p.key.string, cmd[i]) - inc(i) + if i < cmd.len: + add(p.key.string, cmd[i]) + inc(i) p.inShortState = true while i < cmd.len and cmd[i] in {'\t', ' '}: inc(i) @@ -446,7 +447,7 @@ when declared(initOptParser): tuple[kind: CmdLineKind, key, val: TaintedString] = ## Convenience iterator for iterating over command line arguments. ## - ## This creates a new `OptParser<#OptParser>`_. If no command line + ## This creates a new `OptParser<#OptParser>`_. If no command line ## arguments are provided, the real command line as provided by the ## ``os`` module is retrieved instead. ## |