229 std::function<void(const ArgumentList&)>
command;
239 void addDefaultCommand (
Command);
242 void addVersionCommand (
String versionArgument,
String versionText);
248 void addHelpCommand (
String helpArgument,
String helpMessage,
bool makeDefaultCommand);
262 static void fail (
String errorMessage,
int returnCode = 1);
268 static int invokeCatchingFailures (std::function<
int()>&& functionToCall);
285 bool optionMustBeFirstArg =
false)
const;
290 int findAndRunCommand (
int argc,
char* argv[])
const;
302 const std::vector<Command>& getCommands()
const;
306 std::vector<Command> commands;
307 int commandIfNoOthersRecognised = -1;
Array< Argument > arguments
The list of arguments (not including the name of the executable that was invoked).
String getLongOptionValue() const
If this argument is a long option with a value, this returns the value.
ArgumentList(String executable, StringArray arguments)
Creates an argument list for a given executable.
bool isShortOption() const
Returns true if this argument starts with a single dash.
bool isOption() const
Returns true if this argument starts with one or more dashes.
String text
The original text of this argument.
String getValueForOption(StringRef option) const
Looks for a given argument and returns either its assigned value (for long options) or the string tha...
A simple class for holding temporary references to a string literal or String.
int indexOfOption(StringRef option) const
Returns the index of the given string if it matches one of the arguments, or -1 if it doesn't...
Holds a list of command-line arguments, and provides useful methods for searching and operating on th...
File getFileForOption(StringRef option) const
Looks for the value of argument using getValueForOption() and tries to parse that value as a file...
String shortDescription
A short (one line) description of this command, which can be printed by ConsoleApplication::printComm...
A special array for holding a list of strings.
String commandOption
The option string that must appear in the argument list for this command to be invoked.
String argumentDescription
A description of the command-line arguments needed for this command, which will be printed as part of...
Represents a command that can be executed if its command-line arguments are matched.
Argument operator[](int index) const
Returns one of the arguments.
bool operator!=(StringRef stringToCompare) const
Compares this argument against a string.
File resolveAsExistingFolder() const
Resolves a user-supplied folder name into an absolute File, using the current working directory as a ...
One of the arguments in an ArgumentList.
Represents a local file or directory.
Holds a resizable array of primitive or copy-by-value objects.
File resolveAsFile() const
Resolves this argument as an absolute File, using the current working directory as a base for resolvi...
File resolveAsExistingFile() const
Resolves this argument as an absolute File, using the current working directory as a base for resolvi...
File getExistingFileForOption(StringRef option) const
Looks for a file argument using getFileForOption() and fails with a suitable error if the file doesn'...
void checkMinNumArguments(int expectedMinNumberOfArgs) const
Throws an error unless there are at least the given number of arguments.
String executableName
The name or path of the executable that was invoked, as it was specified on the command-line.
bool operator==(StringRef stringToCompare) const
Compares this argument against a string.
void failIfOptionIsMissing(StringRef option) const
Throws an error unless the given option is found in the argument list.
int size() const
Returns the number of arguments in the list.
Represents a the set of commands that a console app can perform, and provides helper functions for pe...
bool isLongOption() const
Returns true if this argument starts with a double dash.
File getExistingFolderForOption(StringRef option) const
Looks for a filename argument using getFileForOption() and fails with a suitable error if the file is...
String longDescription
A longer description of this command, for use in extended help.
std::function< void(const ArgumentList &)> command
The actual command that should be invoked to perform this action.
bool containsOption(StringRef option) const
Returns true if the given string matches one of the arguments.