24#ifndef UTILITY_PROGRAM_H
25#define UTILITY_PROGRAM_H
71 using FUNC = std::function<int(
int argc,
char** argv )>;
Class that handles delegation of command lines to one of a number of "sub-utilities".
UTILITY_PROGRAM::FUNC * findSubUtility(const std::string &aName) const
Find a sub-utility with the given ID/name.
void showSubUtilityList(std::ostream &os) const
Format the list of known sub-utils.
void printUsage(char *name, std::ostream &os) const
Print the command line usage of this program.
int HandleCommandLine(int argc, char **argv) const
Take in a command line and:
RET_CODES
Return codes for tools.
@ UNKNOWN_TOOL
The tool asked for was not found.
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.
Description of a "utility program", which is a program that takes some command line and does "somethi...
std::function< int(int argc, char **argv)> FUNC
A function that provides the program for a given command line.
std::string m_name
The name of the program (this is used to select one)
UTILITY_PROGRAM(const std::string &aName, const std::string &aDesc, FUNC aMainFunc)
FUNC m_func
The function to call to run the program.
std::string m_desc
Description of the program.