Package be.panako.cli
Class Application
java.lang.Object
be.panako.cli.Application
- Direct Known Subclasses:
Clear,Configuration,Delete,Load,Monitor,Play,Print,Query,Resolve,Same,Stats,Store
Application is the abstract base class of applications with a command line interface.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intChecks the configuration and returns either the number of configured number of available processors to use or the maximum number of available processors if the configured value is zero or negative.protected booleanChecks if a file exists and can be read.abstract StringgetFilesFromArguments(String[] arguments) Returns a list of exiting (checked) files in the argument list.protected intgetIntegerOption(String option, int defaultValue, String... arguments) protected StringReturn the value of an option.protected booleanhasArgument(String argument, String... strings) Checks if an argument is present in a list of arguments.final Stringname()The name of the application is the class lower case class name.abstract booleanvoidabstract voidabstract Stringsynopsis()The synopsis is a short description of the required or optional arguments.abstract boolean
-
Constructor Details
-
Application
public Application()
-
-
Method Details
-
run
- Parameters:
args- The arguments to start the program.
-
name
The name of the application is the class lower case class name.- Returns:
- The name of the application.
-
description
- Returns:
- The description of the application. What does it do?
-
synopsis
The synopsis is a short description of the required or optional arguments.- Returns:
- The command line synopsis.
-
needsStorage
public abstract boolean needsStorage()- Returns:
- True if this application needs the storage, false otherwise.
-
getFilesFromArguments
Returns a list of exiting (checked) files in the argument list. If a text (with txt extension) file is found its contents is read and each line in the file interpreted as an absolute path to a file.- Parameters:
arguments- the list of command line arguments- Returns:
- A list of checked file.
-
checkFile
Checks if a file exists and can be read.- Parameters:
file- The file to check.- Returns:
- True if the file exists and can be read. False otherwise.
-
availableProcessors
public static int availableProcessors()Checks the configuration and returns either the number of configured number of available processors to use or the maximum number of available processors if the configured value is zero or negative.- Returns:
- Either the number of configured number of available processors to use or the maximum number of available processors if the configured value is zero or negative.
-
hasArgument
Checks if an argument is present in a list of arguments.- Parameters:
argument- The argument to check for.strings- The given arguments.- Returns:
- True if the argument is in the given list. Case is ignored. False otherwise.
-
getIntegerOption
- Parameters:
option- The argument e.g. "-n".arguments- The list of arguments to search in.- Returns:
- The integer found or the default value.
-
getOption
Return the value of an option. E.g. calling this method with option "-n" and default value 20 on the followingpanako stats --n 10returns 10.- Parameters:
option- The option to look fordefaultValue- The default valuearguments- The arguments to search in- Returns:
- The value of the option, or the provided default.
-
writesToStorage
public abstract boolean writesToStorage()- Returns:
- true if this application writes to storage.
-
printHelp
public void printHelp()
-