Menu

#28 Command line parsing

closed-accepted
nobody
None
5
2010-08-27
2010-08-25
No

Added and used two functions to get a command line option (a "flag") and an option with a value in order to reduce repeated code.

In the long run command line parsing should be done central and with `optparse` (or maybe `wx.CmdLineParser`?). This might need some changes in the way plugins get at command line options though, because `optparse` needs to know all possible options before parsing the command line. One possibility would be an option for plugin options. For example::

--plugin-options 'opt1 "opt 1" opt2'

The option's value could be parsed with `shlex` and bound to `sys.argv` after parsing the options for the main program. This way there would be no difference for existing plugins. Although I think that all accepted options should be known at parsing time, that is very early in the application's life cycle. Applications should fail with misspelled options and not ignore them.

Discussion

  • Marc 'BlackJack' Rintsch

     
  • Franz Steinhaeusler

    Thanks, is in svn

     
  • Franz Steinhaeusler

    • status: open --> open-accepted
     
  • Franz Steinhaeusler

    • status: open-accepted --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.