Allow defaultValueDesc even without defaultValue; Cosmetic changes
This commit is contained in:
parent
5f2f882151
commit
5f7cfa8d98
|
@ -226,7 +226,7 @@ proc writeDesc(help: var string,
|
||||||
descIndent = (5 + appInfo.namesWidth + descSpacing.len)
|
descIndent = (5 + appInfo.namesWidth + descSpacing.len)
|
||||||
remainingColumns = appInfo.terminalWidth - descIndent
|
remainingColumns = appInfo.terminalWidth - descIndent
|
||||||
defaultValSuffix = if defaultValue.len == 0: ""
|
defaultValSuffix = if defaultValue.len == 0: ""
|
||||||
else: " [default: " & defaultValue & "]"
|
else: " [=" & defaultValue & "]"
|
||||||
fullDesc = desc & defaultValSuffix & "."
|
fullDesc = desc & defaultValSuffix & "."
|
||||||
|
|
||||||
if remainingColumns < confutils_narrow_terminal_width:
|
if remainingColumns < confutils_narrow_terminal_width:
|
||||||
|
@ -684,14 +684,12 @@ proc cmdInfoFromType(T: NimNode): CmdInfo =
|
||||||
elif field.readPragma("argument") != nil: Arg
|
elif field.readPragma("argument") != nil: Arg
|
||||||
else: CliSwitch
|
else: CliSwitch
|
||||||
|
|
||||||
if defaultValueDesc != nil and defaultValue == nil:
|
|
||||||
error "The `defaultValueDesc` pragma cannot be specified without also specifying `defaultValue`", defaultValueDesc
|
|
||||||
|
|
||||||
var opt = OptInfo(kind: optKind,
|
var opt = OptInfo(kind: optKind,
|
||||||
idx: fieldIdx,
|
idx: fieldIdx,
|
||||||
name: $field.name,
|
name: $field.name,
|
||||||
isHidden: isHidden,
|
isHidden: isHidden,
|
||||||
defaultValue: if defaultValueOnScreen == nil: ""
|
defaultValue: if defaultValueOnScreen == nil: ""
|
||||||
|
elif defaultValueOnScreen.kind in {nnkStrLit..nnkTripleStrLit}: defaultValueOnScreen.strVal
|
||||||
else: repr(defaultValueOnScreen),
|
else: repr(defaultValueOnScreen),
|
||||||
typename: field.typ.repr)
|
typename: field.typ.repr)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue