[ET Trac] [Einstein Toolkit] #221: Simfactory should complain about unused arguments

Einstein Toolkit trac-noreply at einsteintoolkit.org
Tue Mar 20 10:08:07 CDT 2012


#221: Simfactory should complain about unused arguments
-------------------------+--------------------------------------------------
  Reporter:  eschnett    |       Owner:  mthomas 
      Type:  defect      |      Status:  reopened
  Priority:  major       |   Milestone:          
 Component:  SimFactory  |     Version:          
Resolution:              |    Keywords:          
-------------------------+--------------------------------------------------

Comment (by hinder):

 Regarding arguments:

 Why don't we just add code to each command to check that there are no
 unused arguments after processing the command line?  There are not so many
 simfactory commands.  Also, some of them take a variable number of
 arguments, so there is no way to determine which ones should be provided
 except within the commands themselves.

 Regarding options:

 Is the problem that we don't distinguish between global options and
 command options?  If we could have an option database for the "sim"
 command, and then one for each of the subcommands, it would be easy to
 sort out the mess.  The position of the option relative to the command
 name in the sim command line would indicate whether it was a global option
 or a command option.  In the case of a command option, if it wasn't
 appropriate for that command, it wouldn't be in the command option
 database, and the option framework would complain about it.  SimFactory
 uses the Python "optparse" module
 (http://docs.python.org/library/optparse.html).  The optparse.parse_args()
 function usually reads options from the command line no matter where they
 are, and this prevents us from distinguishing between options before and
 after the command.  However, according to
 http://docs.python.org/library/optparse.html#querying-and-manipulating-
 your-option-parser, you can use the
 OptionParser.disable_interspersed_args() feature to force optparse to stop
 parsing options as soon as it finds a positional argument.  optparse will
 then return all the remaining arguments in a list, which can then be used
 with a new optionparser, depending on the command which is used.

-- 
Ticket URL: <https://trac.einsteintoolkit.org/ticket/221#comment:7>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit


More information about the Trac mailing list