[Tutor] Command lines args (getopt)

Clay Shirky clay at shirky.com
Wed Aug 13 18:27:20 EDT 2003


> I am getting upwards of single character arguments that make sense for a
> program I am writing. I am using getopt to parse the arguments. My
> question is I would like to use two character short options such as -lu
> (for local user) and -ru (for remote user). I know I can acomplish this
> (well almost) with long opts such as --ru, but I am trying to stay away
> from that. Any suggestions?

My suggestion is don't stay away from long opts.

The heuristic for long opts is when you get upwards of single character
arguments that make sense, so don't just add long opts, add them in a way
that makes them readable, as in --remote and --local, or --ruser and
--luser, or whatever makes them comprehensible to your users.

-clay




More information about the Tutor mailing list