Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Parsing Command Line Options

by mmartin (Monk)
on Jan 12, 2012 at 20:51 UTC ( #947637=note: print w/replies, xml ) Need Help??

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

Hey toolic, thanks for the reply.

Right, if they quote it it would not be a problem. But some people using this may not be the most computer savvy people, and I want to just make sure they can't screw it up.


Replies are listed 'Best First'.
Re^3: Parsing Command Line Options
by Tanktalus (Canon) on Jan 12, 2012 at 21:05 UTC

    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 :-) )

      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,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947637]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-10-23 17:57 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (282 votes). Check out past polls.