Sub-Term Mapping Tools

CmdLine with Argument and Config Options

I. Description

This class extends the CmdLine (basic) class to provide basic function of interactive interface for command line tool and read information from command line arguments and configuration file. This class provides following default argument options:
  • -ci: Show configuration information
  • -h: Show program help menu (this is it)
  • -hs: Show hierarchy structure of all options
  • -p: Show prompt
  • -v: Show version of tool
  • -x: Specify an alternate configuration file

The following steps are needed to use this class:

  • make YourClass as a sub-class of CmdLineArgsConfig
    import gov.nih.nlm.nls.stmt.CmdLine.*;
    import gov.nih.nlm.nls.stmt.Lib.*;
    import gov.nih.nlm.nls.lvg.CmdLineSyntax.*;
    public class YourClass extends CmdLineArgsConfig
  • instantiate YourClass and call Run(args) method in the main method
    YourClass yourClass = new YourClass();
    yourClass.Run(args);
  • override following methods
    • protected void InitLocalObjs()
      => instantiate local data members
    • protected void SetToolInfo()
      => set tool info, such as promptStr, tool name, version, config file, etc.
    • protected void CloseLocalObjs()
      => clean up local data members
    • protected void ProcessLine(String line)
      => how to process the input line

    • protected String SetLocalFlagStr()
      => Set argument option flag strings of YourClass
    • protected void SetLocalOptions()
      => Set full name of option flags and help menu of YourClass
    • protected void ExecuteLocalOption(OptionItem nameItem)
      => Set data members based on option flags of YourClass
    • protected void SetLocalDefaultOption()
      => Set data members of YourClass (not based on option flags)

II. Main Algorithm


public void Run(String[] args)
=> Same as CmdLine

protected boolean PreProcess(String[] args)
=> Similar to CmdLineArgs

  • ...
  • SetValues()
    • SetValuesByDefault( );
    • SetValuesByCmdLineOptions( );
    • SetValuesByConfigVars( );
      => set data member values by config vars
  • ...

protected void Process()
=> Same as CmdLine

protected void PostProcess()
=> Same as CmdLine

protected void HelpMenu()

  • Print out help menu
  • Override protected method

III. Abstract Methods

  • protected void InitLocalObjs()
    => instantiate local data members
  • protected void SetToolInfo()
    => set tool info, such as promptStr, tool name, version, config file, etc.
  • protected void CloseLocalObjs()
    => clean up local data members
  • protected void ProcessLine(String line)
    => how to process the input line

  • protected String SetLocalFlagStr()
    => Set argument option flag strings of YourClass
  • protected void SetLocalOptions()
    => Set full name of option flags and help menu of YourClass
  • protected void ExecuteLocalOption(OptionItem nameItem)
    => Set data members based on option flags of YourClass
  • protected void SetLocalDefaultOption()
    => Set data members of YourClass (not based on option flags)