in reply to Re^2: Parsing Command Line Options
in thread Parsing Command Line Options

If they're not that savvy, tell them to stop using spaces in their filenames ;-)

There really is no straight-forward, simple, and portable answer to your question, short of some minor retraining of your users. For example, if I specify "--cfg=my  cfg" with two spaces, there's basically no way to recover that - the shell will eat the spaces. (Some shells may save the original command in an environment variable, but, again, it's not portable, and may not apply to your shell/OS/users.) You could, I suppose, use *'s instead of -'s or _'s and the glob function, but at some point you're getting far too smart and will likely end up getting in trouble.

If you continue to try, you may have to pre-process @ARGV, merging any argument that doesn't start with a dash in with the previous argument. But, even then, it gets annoying, really fast.

Also, your interface will be completely non-standard. Users learning your way of doing things will not be able to apply that knowledge to any other application. However, if you teach them the "normal" way (quoting, or just putting in the dashes if that's what they want to use), that knowledge and experience will then transfer to any other program they use.

Sounds like what you really need is a GUI interface for users who can't handle the command line :-) (And lest that sound condescending, it's not intended to - presumably those users are providing other value to their employer to justify their salary which would be more valuable than another command-line expert :-) )

Replies are listed 'Best First'.
Re^4: Parsing Command Line Options
by mmartin (Monk) on Jan 12, 2012 at 21:16 UTC
    Hey Tanktalus, thanks for your reply.


    Yeah, I guess your right... I was afraid of that lol.

    Ok, I guess I'll just make sure that they use some kind of separators (i.e. '-' or '_')...


    Thanks for the HARD truth haha...


    Thanks Again,
    Matt