edu.cmu.minorthird.util
Interface CommandLineProcessor

All Known Implementing Classes:
BasicCommandLineProcessor, ClassifyCommandLineUtil, ClassifyCommandLineUtil.BaseParams, ClassifyCommandLineUtil.Learner, ClassifyCommandLineUtil.Learner.ClassifierLearner, ClassifyCommandLineUtil.Learner.SequentialLearner, ClassifyCommandLineUtil.MultiTestParams, ClassifyCommandLineUtil.MultiTrainParams, ClassifyCommandLineUtil.MultiTrainTestParams, ClassifyCommandLineUtil.SeqTestParams, ClassifyCommandLineUtil.SeqTrainParams, ClassifyCommandLineUtil.SeqTrainTestParams, ClassifyCommandLineUtil.SimpleTestParams, ClassifyCommandLineUtil.SimpleTrainParams, ClassifyCommandLineUtil.SimpleTrainTestParams, ClassifyCommandLineUtil.TestParams, ClassifyCommandLineUtil.TrainParams, ClassifyCommandLineUtil.TrainTestParams, CommandLineUtil.AnnotatorOutputParams, CommandLineUtil.BaseParams, CommandLineUtil.ClassificationSignalParams, CommandLineUtil.EditParams, CommandLineUtil.ExtractionSignalParams, CommandLineUtil.GUIParams, CommandLineUtil.LoadAnnotatorParams, CommandLineUtil.MixupParams, CommandLineUtil.MultiClassificationSignalParams, CommandLineUtil.OnlineBaseParams, CommandLineUtil.OnlineLearnerParams, CommandLineUtil.OnlineSignalParams, CommandLineUtil.SaveParams, CommandLineUtil.SplitterParams, CommandLineUtil.TaggerSignalParams, CommandLineUtil.TestClassifierParams, CommandLineUtil.TestExtractorParams, CommandLineUtil.TrainClassifierParams, CommandLineUtil.TrainExtractorParams, CommandLineUtil.TrainTaggerParams, CommandLineUtil.ViewLabelsParams, ExtractorNameMatcher.MyCLP, ExtractorTweaker.MyCLP, JointCommandLineProcessor, LabeledDirectory.MyCLP, PreprocessTextForClassifier.LinkFileParams, PreprocessTextForExtractor.ExtractionReductionParams, RankingEvaluation.MyCLP, RankingExpt.MyCLP, Recommended.HMMTokenFE.MyCLP, Recommended.MultitokenSpanFE.MyCLP, Recommended.TokenFE.MyCLP, SpanDifference.Invoker, Test.DataClassificationTask.GUIParams, Train.DataClassificationTask.GUIParams, TrainTest.DataClassificationTask.GUIParams, UI.DataClassificationTask.GUIParams

public interface CommandLineProcessor

A lightweight command-line processing tool.

Author:
William Cohen

Nested Class Summary
static interface CommandLineProcessor.Configurable
          Interface for objects that can be configured with command-line arguments.
 
Method Summary
 int consumeArguments(java.lang.String[] args, int startPos)
          Try to consume a the command-line argument at position i.
 void processArguments(java.lang.String[] args)
          Loop thru the command-line arguments.
 boolean shouldTerminate()
          Specifies whether the commandline processing should terminate.
 void usage()
          Give usage() information.
 void usage(java.lang.String errorMessage)
          Prints errorMessage and then calls usage().
 

Method Detail

processArguments

void processArguments(java.lang.String[] args)
Loop thru the command-line arguments. Option pairs like "-foo bar" should cause a call to x.foo("bar"), where x is this CommandLineProcessor. Options like "-gorp" cause a call to x.gorp(). Options without corresponding methods are considered errors. If an error occurs, then an IllegalArgumentException is thrown.

If function like -foo happens to return a non-null CommandLineProcessor, that processor is invoked on the arguments immediately after foo. This allows one CommandLineProcessor to pass command-line options to a second one. For instance, if x and y are CommandLineProcessors, x has an method colorOpts() that returns y, and y has methods background(String s) and foreground(String t) then the command line sequence -colorOpts -background blue -foreground red would call the expected methods of y.

The optional "-config FILE" should cause a Properties object to be loaded from FILE, and the property/value pairs in the Properties object to be treated as if they were option/argument pairs. The order of lines in the property file may not be preserved, however, and duplicated keys will be ignored.

For instance, calling -config FILE for a FILE containing

baz=
foo=bar
would be the same as the command options -foo bar -baz or possibly -baz -foo bar


consumeArguments

int consumeArguments(java.lang.String[] args,
                     int startPos)
Try to consume a the command-line argument at position i. Return the number of arguments successfully consumed.


usage

void usage(java.lang.String errorMessage)
Prints errorMessage and then calls usage().


usage

void usage()
Give usage() information.


shouldTerminate

boolean shouldTerminate()
Specifies whether the commandline processing should terminate. For example, if the usage is to be displayed, we should ignore other arguments and terminate.