You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I'm missing something, command line parsing is really bad.
You should check out docopt! It's not the only way to do it in nim, but it's pretty nice. It parses your help-text and makes it pretty easy.
Here is an example from a recent project:
import docopt
const doc ="""null0 - Runtime for null0 game-engineUsage: null0 <cart> null0 --help null0 --net <cart><cart> Specify the cart-name (wasm file or zip/directory with main.wasm in it)Options: -h --help Show this screen. -n,--net Allow cart to access networking"""procmain() =let args =docopt(doc, version ="0.0.1")
if args["--net"]:
# do net stuffcartLoad($args["<cart>"])
It adds all the options and understands -n,--net are aliases, and other little things. It knows it should demand a <cart> and shows a simplified help, if you don't provide it. It seems pretty tolerant of different formats (like I added documentation for <cart> in a few places, and it kept working, fine.)
The text was updated successfully, but these errors were encountered:
You mention in README
You should check out docopt! It's not the only way to do it in nim, but it's pretty nice. It parses your help-text and makes it pretty easy.
Here is an example from a recent project:
It adds all the options and understands
-n,--net
are aliases, and other little things. It knows it should demand a<cart>
and shows a simplified help, if you don't provide it. It seems pretty tolerant of different formats (like I added documentation for<cart>
in a few places, and it kept working, fine.)The text was updated successfully, but these errors were encountered: