Created
October 22, 2022 04:13
-
-
Save MrEnder0/662e7952137923eddafcf1bfa626981c to your computer and use it in GitHub Desktop.
A docopt template for the nim language.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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