iffy / nim-argparse

Argument parsing for Nim
MIT License
120 stars 8 forks source link

help() procedure only takes a constant string #75

Open not-lum opened 2 years ago

not-lum commented 2 years ago

help() procedure only takes a constant string, but what if I want to change help text depending on the situation? Example:

var helpText = "..."

if not trueColorSupport:
  helpText &= "\nWARNING: your terminal emulator does not support true colors"

var parser = newParser:
  help(helpText)
  ...
iffy commented 2 years ago

Since the parser is generated at compile-time, if you're able to build up the string during compile time, it will work. I can see the value in what you're asking though. Perhaps help() could be made to also accept a zero-argument function.

levovix0 commented 1 year ago

This will also be useful for localizing help messages.