KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KI_TEST::COMBINED_UTILITY Class Reference

Class that handles delegation of command lines to one of a number of "sub-utilities". More...

#include <utility_program.h>

Public Member Functions

int HandleCommandLine (int argc, char **argv) const
 Take in a command line and: More...
 

Private Member Functions

void showSubUtilityList (std::ostream &os) const
 Format the list of known sub-utils. More...
 
UTILITY_PROGRAM::FUNCfindSubUtility (const std::string &aName) const
 Find a sub-utility with the given ID/name. More...
 
void printUsage (char *name, std::ostream &os) const
 Print the command line usage of this program. More...
 

Detailed Description

Class that handles delegation of command lines to one of a number of "sub-utilities".

Definition at line 97 of file utility_program.h.

Member Function Documentation

◆ findSubUtility()

UTILITY_PROGRAM::FUNC * KI_TEST::COMBINED_UTILITY::findSubUtility ( const std::string &  aName) const
private

Find a sub-utility with the given ID/name.

Parameters
aNamethe desired sub-utility name (e.g. "drc")
Returns
pointer to the function that runs that sub-utility

Definition at line 42 of file utility_program.cpp.

References UTILITY_REGISTRY::GetInfoMap(), and KI_TEST::UTILITY_PROGRAM::m_func.

Referenced by HandleCommandLine().

◆ HandleCommandLine()

int KI_TEST::COMBINED_UTILITY::HandleCommandLine ( int  argc,
char **  argv 
) const

Take in a command line and:

  • Handle "top level" commands like -h and -l
  • Delegate to sub-utilities
  • Report malformed command lines
Parameters
argcargument count (directly from the main() parameter )
argvargument values (directly from the main() parameter )
Returns
return code

Definition at line 75 of file utility_program.cpp.

References KI_TEST::BAD_CMDLINE, findSubUtility(), KI_TEST::OK, printUsage(), showSubUtilityList(), and KI_TEST::UNKNOWN_TOOL.

Referenced by main(), and APP_TEST::OnInit().

◆ printUsage()

void KI_TEST::COMBINED_UTILITY::printUsage ( char *  name,
std::ostream &  os 
) const
private

Print the command line usage of this program.

Parameters
namethe name the program was run with
osstream to print to

Definition at line 59 of file utility_program.cpp.

References name, and showSubUtilityList().

Referenced by HandleCommandLine().

◆ showSubUtilityList()

void KI_TEST::COMBINED_UTILITY::showSubUtilityList ( std::ostream &  os) const
private

Format the list of known sub-utils.

Parameters
osthe stream to format on

Definition at line 31 of file utility_program.cpp.

References UTILITY_REGISTRY::GetInfoMap(), KI_TEST::UTILITY_PROGRAM::m_desc, and KI_TEST::UTILITY_PROGRAM::m_name.

Referenced by HandleCommandLine(), and printUsage().


The documentation for this class was generated from the following files: