#!/usr/bin/python3 from pyqi.core.interfaces.optparse import (OptparseOption, OptparseUsageExample, OptparseOption, OptparseResult) from pyqi.commands.make_command import CommandConstructor # If you need access to input or output handlers provided by pyqi, consider # importing from the following modules: # pyqi.core.interfaces.optparse.input_handler # pyqi.core.interfaces.optparse.output_handler # pyqi.interfaces.optparse.input_handler # pyqi.interfaces.optparse.output_handler # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample(ShortDesc="A short single sentence description of the example", LongDesc="A longer, more detailed description", Ex="%prog --foo --bar some_file") ] # inputs map command line arguments and values onto Parameters. It is possible # to define options here that do not exist as parameters, e.g., an output file. inputs = [ # An example option that has a direct relationship with a Parameter. # OptparseOption(Parameter=CommandConstructor.Parameters['name_of_a_parameter'], # InputType='existing_filepath', # the optparse type of input # InputHandler=None, # Apply a function to the input value to convert it into the type expected by Parameter.DataType # ShortName='n', # a parameter short name, can be None # # Name='foo', # implied by Parameter. Can be overwritten here if desired # # Required=True, # implied by Parameter. Can be promoted by setting True # # Help, # implied by Parameter.Description. Can be overwritten here if desired # convert_to_dashed_name=True), # whether the Name (either implied by Parameter or defined above) should have underscores converted to dashes when displayed to the user # # An example option that does not have an associated Parameter. # OptparseOption(Parameter=None, # InputType='new_filepath', # InputHandler=None, # we don't need an InputHandler because this option isn't being converted into a format that a Parameter expects # ShortName='o', # Name='output-fp', # Required=True, # Help='output filepath') OptparseOption(Parameter=CommandConstructor.Parameters['license'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='license', # implied by Parameter # Required=True, # implied by Parameter # Help='the license for the Command', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['name'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='name', # implied by Parameter # Required=True, # implied by Parameter # Help='the name of the Command', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['copyright'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='copyright', # implied by Parameter # Required=True, # implied by Parameter # Help='the Command copyright', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['author'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='author', # implied by Parameter # Required=True, # implied by Parameter # Help='the Command author', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['credits'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='credits', # implied by Parameter # Required=False, # implied by Parameter # Help='comma-separated list of other authors', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['command_version'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='command_version', # implied by Parameter # Required=True, # implied by Parameter # Help='the Command version', # implied by Parameter OptparseOption(Parameter=CommandConstructor.Parameters['email'], InputType=, InputHandler=None, # must be defined if desired ShortName=None), # must be defined if desired # Name='email', # implied by Parameter # Required=True, # implied by Parameter # Help='maintainer email address', # implied by Parameter ] # outputs map result keys to output options and handlers. It is not necessary # to supply an associated option, but if you do, it must be an option from the # inputs list (above). outputs = [ # An example option that maps to a result key. # OptparseResult(ResultKey='some_result', # OutputHandler=write_string, # a function applied to the value at ResultKey # # # the name of the option (defined in inputs, above), whose # # value will be made available to OutputHandler. This name # # can be either an underscored or dashed version of the # # option name (e.g., 'output_fp' or 'output-fp') # OptionName='output-fp'), # # An example option that does not map to a result key. # OptparseResult(ResultKey='some_other_result', # OutputHandler=print_string) ]