HappyDoc Generated Documentation Class: CommandLineApp

HappyDoc3-r3_1 / happydoclib / CommandLineApp.py / CommandLineApp 

Base class for building command line applications.

Define a __doc__ string for the class to explain what the program does.

When the argumentsDescription field is not empty, it will be printed appropriately in the help message.

When the examplesDescription field is not empty, it will be printed last in the help message when the user asks for help.

Methods   
  debugMethodEntry 
debugMethodEntry (
        self,
        methodName,
        debugLevel=3,
        **nargs,
        )

Print a method entry debug statement with named arguments.

  appInit 
appInit ( self )

Override this method to perform application initialization.

This hook may be easier to override than the __init__ method, since it takes no parameters.

  getOptionHelpString 
getOptionHelpString (
        self,
        dashInsert,
        option,
        valueInsert,
        docString,
        )

Build the help string for an option.

  showOptionHelp 
showOptionHelp (
        self,
        dashInsert,
        option,
        valueInsert,
        docString,
        )

Format and print the help message for a single option.

  __init__ 
__init__ ( self,  commandLineOptions=sys.argv [ 1 : ] )

Initialize CommandLineApp.

  showHelp 
showHelp ( self,  errorMessage=None )

Display help message when error occurs.

  methodNameFromOption 
methodNameFromOption ( self,  option )

Given the name of an option, construct and return the name of the method to handle it.

  optionHandler_q 
optionHandler_q ( self )

Turn on quiet mode.

  showVerboseSyntaxHelp 
showVerboseSyntaxHelp ( self )

Show a full description of all options and arguments.

  optionHandler_v 
optionHandler_v ( self )

Increment the verbose level. Higher levels are more verbose. The default is 1.

  main 
main ( self,  *args )

Main body of your application.

This is the main portion of the app, and is run after all of the arguments are processed. Override this method to implment the primary processing section of your application.

  statusMessage 
statusMessage (
        self,
        msg='',
        verboseLevel=1,
        error=None,
        )

Print a status message to output.

Arguments
msg=''
The status message string to be printed.
verboseLevel=1
The verbose level to use. The message will only be printed if the current verbose level is >= this number.
error=None
If true, the message is considered an error and printed as such.
  run 
run ( self )

Entry point.

Process options and execute callback functions as needed. This method should not need to be overridden, if the main() method is defined.

  showSimpleSyntaxHelp 
showSimpleSyntaxHelp ( self )

Show basic syntax message.

  errorMessage 
errorMessage ( self,  msg='' )

Print a message as an error.

  __init_getopt__ 
__init_getopt__ ( self )

Parse the command line options.

Exceptions   

getopt.error, message

  longOptionsListGet 
longOptionsListGet ( self )

Given the information learned through self.__learnValidOpts__, construct a list to be passed to getopt to set the valid long form option syntax.

  infoForOption 
infoForOption ( self,  option )

Get the stored information about an option.

  __learnValidOpts__ 
__learnValidOpts__ ( self )

Derive the options which are valid for this application.

Examine the methods defined for this class to learn what options the developer wants to use. Options can be added by defining an optionHandler method with a name like optionHandler_

  getVerboseSyntaxHelpString 
getVerboseSyntaxHelpString ( self )

Return the full description of the options and arguments.

Show a full description of the options and arguments to the command in something like UNIX man page format. This includes

  • a description of each option and argument, taken from the __doc__ string for the optionHandler method for the option
  • a description of what additional arguments will be processed, taken from the class member argumentsDescription

  constructOptionInfo 
constructOptionInfo (
        self,
        methodName,
        methodRef,
        )

Return an info tuple for an option handler method.

Given a method name, return the information tuple for that option to the program. The tuple contains:

(option name, flag showing whether the option takes a value, flag indicating long or short form option, help string for option)

  getSimpleSyntaxHelpString 
getSimpleSyntaxHelpString ( self )

Return syntax statement.

Return a simplified form of help including only the syntax of the command.

  shortOptionsStringGet 
shortOptionsStringGet ( self )

Given the information learned through self.__learnValidOpts__, construct a string to be passed to getopt to set the valid single character option syntax.

  showVerboseHelp 
showVerboseHelp ( self )

Show a verbose help message explaining how to use the program.

This includes:
  • a verbose description of the program, taken from the __doc__ string for the class
  • an explanation of each option, produced by showVerboseSyntaxHelp()
  • examples of how to use the program for specific tasks, taken from the class member examplesDescription
  handleHelpOption 
handleHelpOption ( self )
Exceptions   

self.HelpRequested, 'Help message was printed.'

  scanClassForOptions 
scanClassForOptions ( self,  cRef )

Scan through the inheritence hierarchy to find option handlers.

Exceptions   

CommandLineApp.ReservedOptionName, 'h'

  methodReferenceFromName 
methodReferenceFromName ( self,  methodName )

Return a reference to the method with the given name.


This document was automatically generated Tue Dec 5 08:30:26 2006 by HappyDoc version 3.1