mpeterv / argparse

Feature-rich command line parser for Lua
MIT License
251 stars 43 forks source link

Allow offset for argument parsing #7

Closed bitinn closed 8 years ago

bitinn commented 8 years ago

This might sound strange. But instead of lua script.lua --options, I am doing love . --options as I am using the LOVE engine.

Currently argparse expects me to add a parser:argument to account for the . folder, which is fine. But the help message isn't really what we want:

Usage: love [-d] [-h] <folder/>

love itself takes parameter so love -d . won't do much good.

I think a better option would be to enable argument parsing offset, ignore the . as it's handled by LOVE. I know this is rather an edge case, so it's up to your decision.

ref: https://love2d.org/wiki/Getting_Started

bitinn commented 8 years ago

Another option might be love . -- --options use -- as an indicator for parameters intended for the lua game script iteself.

mpeterv commented 8 years ago

Parser:parse() can take an array of arguments to parse instead of global arg. You can create a copy of it but without the dot argument, or just remove it from the original using table.remove(arg, 1) if you don't mind mutating it.

bitinn commented 8 years ago

Ah great, I should read the doc more carefully