Skip to content

Instantly share code, notes, and snippets.

@MrEnder0
Created October 22, 2022 04:13
Show Gist options
  • Save MrEnder0/662e7952137923eddafcf1bfa626981c to your computer and use it in GitHub Desktop.
Save MrEnder0/662e7952137923eddafcf1bfa626981c to your computer and use it in GitHub Desktop.
A docopt template for the nim language.
import docopt
const doc = """
Usage:
Program (about | a)
Program (reply | r) <prase> [options]
Options:
--forever Loops forever
"""
proc about() =
echo "This is a example program"
proc reply(prase: string, forever: bool) =
echo "You said: " & prase
while forever:
echo "You said: " & prase
proc main() =
let args = docopt(doc, version = "0.0.1")
if args["about"] or args["a"]:
about()
if args["reply"] or args["r"]:
reply($args["<prase>"], args["--forever"])
when isMainModule:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment