Isop infers parameters

Isop infers parameters

21 Sep 2013

Command line tools should do what people expect. It’s a bit chaotic to navigate how to parse command line parameters since there are many conventions.

  • A single - to indicate a short parameter, that is: -a
  • Two – to indicate a long parameter, that is: –alpha
  • A single / to indicate a parameter, that is: /alpha
  • A single - to indicate a parameter, that is: -alpha
  • A parameter followed by a space and then a value for that parameter: /alpha value
  • A parameter followed by a = and then a value for that parameter: –alpha=value
  • The position of the parameter (the ordinal position) to indicate simply a value

I’ve added code to try to infer value for a parameter using it’s ordinal position when there are no ordinary parameters present before the inferred parameter value.

This simply means that it should be possible to write:

my.exe --param1=something --param2=someother

and also:

my.exe something someother

Tags

  • cli
  • option

Comments

Do you want to send a comment or give me a hint about any issues with a blog post: Open up an issue on GitHub.

Do you want to fix an error or add a comment published on the blog? You can do a fork of this post and do a pull request on github.