45 #include "rnr/rnrconfig.h" 87 "A RoadNarrows Robotics librnr_appkit CLI example program.",
90 "The %P command demonstrates the use of librnr_appkit's CommandLine, " 91 "ReadLine, LogBook, RegEx classes to build a command line interface.",
110 #if 0 // SHOW_VERBATIM 120 #endif // SHOW_VERBATIM 130 " /./\\ )______ \\__ \\",
131 " ./ / /\\ \\ | \\ \\ \\ \\",
132 " / / \\ \\ | |\\ \\ \\7",
136 #if 0 // SHOW_VERBATIM 146 #endif // SHOW_VERBATIM 155 " ::.___.-:{|}:--..-::;",
156 " \"=___ '_' ,..-\"",
163 #if 0 // SHOW_VERBATIM 173 #endif // SHOW_VERBATIM 181 " \\`.|\\..----''` / /`'--.,.,, ~''",
182 " / ' ` / /,/ / / ,,. - ~,,",
183 " )/' _/ \\ / `-_,/ / - \",,,' ",
184 " | /' `\"\\_ ,_.-;_.-\\_ ', '',,,'",
185 " |/ _.-'_/ <__.' ; ",
190 #if 0 // SHOW_VERBATIM 208 #endif // SHOW_VERBATIM 232 " (\\ _ /\\ \\ \\ / ).'",
240 #if 0 // SHOW_VERBATIM 255 #endif // SHOW_VERBATIM 277 " /oo |--.--,--,--.",
278 " \\_.-'._i__i__i_.'",
279 " \"\"\"\"\"\"\"\"\"",
283 #if 0 // SHOW_VERBATIM 293 #endif // SHOW_VERBATIM 310 #if 0 // SHOW_VERBATIM 320 #endif // SHOW_VERBATIM 337 #if 0 // SHOW_VERBATIM 346 #endif // SHOW_VERBATIM 353 {
" |''''|\"> ", NULL},
354 {
" |\\'''|\\\">", NULL},
355 {
" /\\'''/\\\">", NULL},
356 {
" /|''/|\"> ", NULL}
369 for(
int i = 0; art[i] != NULL; ++i)
371 os << art[i] << endl;
390 const char *art2[] = NULL,
391 const char *art3[] = NULL)
400 const char **pieces[4];
418 for(i = 0; i < nPieces; ++i)
423 for(j = 0; pieces[i][j] != NULL; ++j)
425 len = strlen(pieces[i][j]);
426 if( len > maxlen[i] )
433 if( linecnt[i] > maxlinecnt )
435 maxlinecnt = linecnt[i];
439 char ofill = os.fill();
440 size_t owidth = os.width();
445 for(
int line = 0; line < maxlinecnt; ++line)
447 for(i = 0; i < nPieces; ++i)
449 if( linecnt[i] >= maxlinecnt-line )
451 j = linecnt[i] - (maxlinecnt - line);
453 len = strlen(pieces[i][j]);
454 os << pieces[i][j] << setw(maxlen[i]-len+1) <<
"";
458 os << setw(maxlen[i]) <<
"";
540 if( strCommonName == Animals[i].m_sCommonName )
556 const string CliName(
"Adopt-An-Animal");
564 #define PERROR(_err) \ 565 cout << CliName << ": " << "Error: " << _err << endl 567 #define PWARN(_warn) \ 568 cout << CliName << ": " << _warn << endl 570 #define PCMDERROR(_cmd, _err) \ 571 cout << CliName << ": " << _cmd << ": " << "Error: " << _err << endl 573 #define PCMDWARN(_cmd, _warn) \ 574 cout << CliName << ": " << _cmd << ": " << _warn << endl 594 const string &strDefName =
Cli.
at(argv0.
uid()).getName();
596 if( !strTgtName.empty() && (strTgtName != strDefName) )
598 PERROR(
"Command execution is for '" << strTgtName <<
"' " 599 <<
"not input command '" << strDefName <<
"'");
604 PERROR(
"Command '" << strDefName <<
"' has missing arguments.");
627 static const char *cmdname =
"adopt";
629 size_t argc = argv.size();
632 if(
checkCmd(argv[0], argc, cmdname) != OK )
642 string animal = argv[n].s();
648 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
654 PCMDWARN(cmdname,
"The " << animal <<
" is already adopted.");
674 static const char *cmdname =
"sleep";
676 size_t argc = argv.size();
682 if(
checkCmd(argv[0], argc, cmdname) != OK )
693 string animal = argv[n].s();
699 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
705 PCMDWARN(cmdname,
"The " << animal <<
" is not yours to rock to sleep.");
724 cout <<
"The " << p->
m_sCommonName <<
" is sleeping for " << secs
725 <<
" seconds." << endl;
739 static const char *cmdname =
"name";
741 size_t argc = argv.size();
744 if(
checkCmd(argv[0], argc, cmdname) != OK )
755 string animal = argv[n].s();
761 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
767 PCMDWARN(cmdname,
"You have not adopted the " << animal <<
".");
787 static const char *cmdname =
"namaste";
789 cout <<
"Aye. Baaaa to the divine Ewe." << endl;
803 static const char *cmdname =
"feed";
805 size_t argc = argv.size();
808 if(
checkCmd(argv[0], argc, cmdname) != OK )
819 string animal = argv[n].s();
825 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
831 PCMDWARN(cmdname,
"The " << animal <<
" is not yours to feed.");
837 const char **food = NULL;
840 if( argv[n] ==
"ants" )
845 else if( argv[n] ==
"carrots" )
850 else if( argv[n] ==
"grubs" )
855 else if( argv[n] ==
"vitamins" )
862 PCMDERROR(cmdname,
"Unknown food '" << argv[n] <<
"'.");
874 cout <<
"Delicious! Give me " << fSecs <<
" seconds to enjoy." << endl;
892 static const char *cmdname =
"walk";
894 size_t argc = argv.size();
897 if(
checkCmd(argv[0], argc, cmdname) != OK )
908 string animal = argv[n].s();
914 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
920 PCMDWARN(cmdname,
"The " << animal <<
" is not yours to walk.");
926 double minutes = argv[n].f();
932 cout <<
"You are walking the " << p->
m_sCommonName <<
" for " << minutes
933 <<
" minutes." << endl;
944 for(
int i = 0; i < 40; ++i)
947 printf(
"%*s%s\r", i,
" ", gait);
953 printf(
"%*s\r", 80,
" ");
970 static const char *cmdname =
"list";
991 static const char *cmdname =
"get";
993 size_t argc = argv.size();
999 if(
checkCmd(argv[0], argc, cmdname) != OK )
1010 string animal = argv[n].s();
1016 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
1020 string strAdoptState;
1023 strAdoptState = p->
m_bIsAdopted?
"Adopted":
"Not adopted";
1028 strActivity =
"Just chill'n dude.";
1031 strActivity =
"Sleeping, don't wake me.";
1034 strActivity =
"Num, num, num.";
1037 strActivity =
"And I'm walking, and walking, walking...";
1040 strActivity =
"I dunno what I'm doing.";
1058 eState = argv[n].e();
1064 cout << strAdoptState << endl;
1070 cout << strActivity << endl;
1081 cout << strAdoptState << endl;
1083 cout << strActivity << endl;
1086 PCMDERROR(cmdname,
"Unknown state '" << argv[n].arg() <<
"'.");
1103 static const char *cmdname =
"reward";
1105 size_t argc = argv.size();
1108 if(
checkCmd(argv[0], argc, cmdname) != OK )
1119 string animal = argv[n].s();
1125 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
1131 PCMDWARN(cmdname,
"The " << animal <<
" is not yours to reward.");
1137 bool isGood = argv[n].b();
1145 cout <<
"is a good girl." << endl;
1146 cout <<
"She ate all of those pesky ants pilfering food in the kitchen." 1151 cout <<
"was a bad girl." << endl;
1152 cout <<
"She dug under the foundation again." << endl;
1160 cout <<
"is a good boy." << endl;
1161 cout <<
"You are now well groomed and free of fleas." << endl;
1165 cout <<
"is a mischieveus boy." << endl;
1166 cout <<
"Why does he love reality tv so much?" << endl;
1174 cout <<
"is a good lad." << endl;
1175 cout <<
"Those termites won't be invading any time soon." << endl;
1179 cout <<
"is a snarky lad." << endl;
1180 cout <<
"He needs to quit putting his long, narrow tongue where it " 1181 <<
"doesn't belong!" << endl;
1189 cout <<
"is a good lass." << endl;
1190 cout <<
"You rode her all the way to town this time without being " 1191 <<
"thrown." << endl;
1195 cout <<
"is a very naughty lass." << endl;
1196 cout <<
"She ate all of the apples ripening on the tree." << endl;
1202 cout <<
" is " << (isGood?
"good":
"not good") <<
"." << endl;
1217 static const char *cmdname =
"save";
1219 size_t argc = argv.size();
1222 if(
checkCmd(argv[0], argc, cmdname) != OK )
1233 string animal = argv[n].s();
1239 PCMDERROR(cmdname,
"Unknown animal '" << animal <<
"'.");
1245 string filename = argv[n].s();
1248 if( access(filename.c_str(), F_OK) == 0 )
1253 cout <<
"Overwrite file '" << argv[n] <<
"'? [ny] ";
1255 if( std::getline(cin, line) )
1257 istringstream iss(line);
1258 if( (iss >> ans) && (ans ==
"y") )
1273 selfie.open(filename.c_str());
1275 if( selfie.is_open() )
1279 cout <<
"A " << p->
m_sCommonName <<
" selfie writen to file '" 1280 << argv[n] <<
"'." << endl;
1284 PCMDERROR(cmdname,
"Failed to open file '" << argv[n] <<
"'.");
1307 "Adopt an available animal",
1308 "Adopt a cuddly animal. In order to name, feed, walk, sleep, or reward " 1310 "you must adopt first. See the 'list' command for list of animals and " 1311 "the 'get' command for an animal's current state of being.\n\n" 1312 "Demonstrates a variable with default 'word' type." 1318 "sleep <animal> [<seconds:int>]",
1319 "Sleep for some <seconds> because, why not?",
1320 "Put your adopted animal to sleep (no, not kill you brute). " 1321 "The <animal> goes to sleep for the given seconds.\n" 1322 " Default: 10 seconds\n\n" 1323 "Demonstrates an optional integer variable argument." 1329 "name <animal> <itsname:multiword>",
1330 "Name your cute adopted pet.",
1331 "Name your adopted animal. Double qoute '\"' the name if it contains " 1332 "any whitespace.\n\n" 1333 "Demonstrates a multword variable argument type." 1340 "Bow to the divine ewe.",
1342 "Demonstrates commands with similar names such as 'name' and 'namaste'." 1349 "feed {aardvark | mandrill | numbat} {ants | grubs}\n" 1350 "feed {mandrill | zebra} carrots\n" 1351 "feed <animal:re(^a.+k$|^m.+l$|^n.+t$|^z.+a$)> vitamins",
1352 "Feed your pet some nutritious food.",
1353 "Feed your adopted animal. Of course, the food has to match the " 1354 "animal's diet.\n\n" 1355 "Demonstrates multi-form commands and enumerated literal arguments.\n" 1356 "Demonstrates a regular expresson variable argument type." 1362 "walk <animal> <minutes:fpn(0.5,1:3)>",
1363 "Walk your adopted pet for some fun-filled <minutes>",
1364 "Walk your adopted animal for the specified minutes.\n\n" 1365 "Demonstrates a floating-point number variable argument." 1372 "Get the list of animals.",
1378 "get <animal> [{all | adoption | given | activity | species | selfie}]",
1379 "Get an animal's current (partial) state.",
1380 "Get the animal's state of being.\n" 1382 "Demonstrates optional enumerated literal arguments." 1388 "reward <animal:identifier> <good:bool>",
1389 "Do [not] reward your pet for its behaviour.",
1390 "Reward your adopted animal or not.\n\n" 1391 "Demonstrates a identifier variable argument.\n" 1392 "Demonstrates a boolean variable argument." 1398 "save <animal:word> <fname:file>",
1399 "Save ascii animal to file.",
1400 "Save an animal's ASCII redention to a file. The art is fantastic btw." 1401 "If the file exist, you will be prompted if you wish to overwrite.\n\n" 1402 "Demonstrates a file variable argument type." 1424 if( strName == Commands[i].m_desc.name )
1437 static const char *CliTestCmdName =
"clitest";
1457 if( nArg >= argv.size() )
1459 PCMDERROR(CliTestCmdName, argv[nCmd] <<
": No <cmd> specified.");
1463 PCMDERROR(CliTestCmdName, argv[nCmd]
1464 <<
": Unknown <cmd> '" << argv[nArg] <<
"'.");
1466 else if( cli.
hasCmd(argv[nArg].s()) )
1468 PCMDERROR(CliTestCmdName, argv[nCmd]
1469 <<
": The <cmd> '" << argv[nArg]
1470 <<
"' is already present in the interface.");
1475 PCMDERROR(CliTestCmdName, argv[nCmd]
1476 <<
": Failed to add <cmd> '" << argv[nArg] <<
"': " 1479 else if( (rc = cli.
compile()) != OK )
1481 PCMDERROR(CliTestCmdName, argv[nCmd]
1482 <<
": Failed to (re)compile interface: " 1487 cout <<
"Command '" << argv[nArg] <<
", uid(" << nUid <<
") added." 1527 if( (rc = cli.
compile()) != OK )
1529 PCMDERROR(CliTestCmdName, argv[nCmd]
1530 <<
": Failed to (re)compile interface: " 1536 cout <<
"Compiled " << cli.
numOfCmds() <<
" commands." << endl;
1560 if( nArg < argv.size() )
1562 if( cli.
at(argv[nArg].s()).getUid() ==
NoUid )
1564 PCMDERROR(CliTestCmdName, argv[nCmd]
1565 <<
": The <cmd> '" << argv[nArg]
1566 <<
"' is not present in the interface.");
1571 cout << cli.
at(argv[nArg].s()) << endl;
1579 cout << cli << endl;
1600 cout <<
"Press any key, 's' to stop test." << endl;
1607 cout <<
" \r" << std::flush;
1620 cout <<
"\r" << std::flush;
1645 if( nArg >= argv.size() )
1647 PCMDERROR(CliTestCmdName, argv[nCmd] <<
": No <attr> specified.");
1650 else if( argv[nArg] ==
"name" )
1652 cout << cli.
getName() << endl;
1654 else if( argv[nArg] ==
"prompt" )
1658 else if( argv[nArg] ==
"numcmds" )
1662 else if( argv[nArg] ==
"errstr" )
1668 PCMDERROR(CliTestCmdName, argv[nCmd]
1669 <<
": Unknown <attr> '" << argv[nArg] <<
"'.");
1693 if( nArg < argv.size() )
1700 PCMDERROR(CliTestCmdName, argv[nCmd] <<
": No <prompt> specified.");
1726 if( nArg >= argv.size() )
1728 PCMDERROR(CliTestCmdName, argv[nCmd] <<
": No <cmd> specified.");
1730 else if( (nUid = cli.
at(argv[nArg].s()).getUid()) ==
NoUid )
1732 PCMDERROR(CliTestCmdName, argv[nCmd]
1733 <<
": The <cmd> '" << argv[nArg]
1734 <<
"' is not present in the interface.");
1738 PCMDERROR(CliTestCmdName, argv[nCmd]
1739 <<
": Failed to remove <cmd> '" << argv[nArg] <<
"': " 1744 cout <<
"Command '" << argv[nArg] <<
"', uid(" << nUid <<
") removed." 1765 if(
checkCmd(argv[nCmd], argv.size()) != OK )
1773 else if( argv[nCmd] ==
"tadd" )
1781 else if( argv[nCmd] ==
"tbt" )
1789 else if( argv[nCmd] ==
"tcompile" )
1797 else if( argv[nCmd] ==
"tdump" )
1805 else if( argv[nCmd] ==
"tkbhit" )
1813 else if( argv[nCmd] ==
"tprint" )
1821 else if( argv[nCmd] ==
"tpush" )
1829 else if( argv[nCmd] ==
"tpop" )
1838 else if( argv[nCmd] ==
"tremove" )
1845 PCMDERROR(CliTestCmdName,
1846 "Do not know how to execute '" << argv[nCmd] <<
"'.");
1868 "<clitest:re(^t[abcdkpr].+)> [<modifier:multiword>]",
1869 "Test CommandLine interface features.",
1870 "The 'clitest' command validates command wild carding and provides test " 1871 "functions to validate the CommandLine and underlining classes.\n\n" 1872 "Supported Test Functions:\n" 1873 " tadd <cmd> - Add command to interface.\n" 1874 " tbt - Backtrace log.\n" 1875 " tcompile - (Re)compile interface.\n" 1876 " tdump [<cmd>] - Dump all or <cmd> definitions.\n" 1877 " tkbhit - Check for keyboard hits.\n" 1878 " tprint <attr> - Print attribute, where <attr> is one of:\n" 1879 " name prompt numcmds errstr.\n" 1880 " tpush <prompt> - Push new <prompt> string.\n" 1881 " tpop - Pop current prompt string.\n" 1882 " tremove <cmd> - Remove command from interface.\n\n" 1883 "Demonstrates command name wild carding.\n" 1884 "Demonstrates regular expresson variable argument type." 1912 Argv0 = basename(argv[0]);
1925 fNow = ActivityTime.
now();
1929 if( Animals[i].m_eActivity ==
ActIdle )
1934 if( (fNow - Animals[i].m_fActStart) >= Animals[i].m_fActDuration )
1962 nUid = cli.
addCommand(Commands[i].m_desc, Commands[i].m_fnExec);
1966 PERROR(
"Failed to add command '" << Commands[i].m_desc.name <<
"'.");
1976 nUid = cli.
addCommand(Command3s[i].m_desc, Command3s[i].m_fnExec);
1980 PERROR(
"Failed to add command '" << Command3s[i].m_desc.name <<
"'.");
1995 if( (rc = cli.
compile()) != OK )
1997 PERROR(
"Compile failed.");
1998 cerr <<
"(backtrace)" << endl;
2028 if( argv.size() > 0 )
2063 PERROR(
"Failed to load commands.");
2071 cout <<
CliName <<
" CommandLine/ReadLine/LogBook/RegEx Example" << endl;
2072 cout <<
" (enter 'help' for list of commands)" << endl << endl;
2076 PERROR(
"Failed to run commands.");
void popPrompt()
Pop prompt string from stack of prompts.
AnimalInfo Animals[]
The animals.
const char ** m_sSelfie
ASCII selfie.
Command line extended argument interface.
static OptsInfo_T OptsInfo[]
Command line options information.
const string CliPrompt("aaa> ")
CLI prompt.
Command EXTended ARGument class holding parsed command context and the raw and converted argmument va...
Self-Reference command description and exectuion structure.
static int execWalkAnimal(const CmdExtArgVec &argv)
Execute 'walk' command.
static const char * AsciiZebra[]
ASCII zebra.
Command line interface command add-ons interface.
#define APP_EC_EXEC
execution exit code
bool m_bIsAdopted
is [not] adopted
virtual int execute(const str::StringVec &argv)
Execute a comamnd with the given arguments.
static const char * AsciiZebraSmall[]
ASCII small zebra.
AppCmdExec Commands[]
The command descriptions.
static ostream & operator<<(ostream &os, const char *art[])
ASCII art output stream operator.
static void showAsciiArt(ostream &os, const char *art0[], const char *art1[], const char *art2[]=NULL, const char *art3[]=NULL)
Write a set of ASCII art to cout.
const size_t NumOfCmd3s
Number of commands.
CmdExec2Func m_fnExec
command execution function
int checkCmd(const CmdExtArg &argv0, int argc, const string strTgtName="")
Check if command input is matched correctly with the command execution.
static int execTRemove(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tremove subcommand.
Activity
Animal activities.
static int execTDump(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tdump subcommand.
Time functions and class interfaces.
virtual int removeCommand(const int uid)
Remove command from command line interface.
Time ActivityTime
activity time
const char * NoName
'no name' name
CmdExec3Func m_fnExec
command execution function
int(* CmdExec2Func)(const CmdExtArgVec &argv)
Command execution function type, variant 2.
static int execAdopt(const CmdExtArgVec &argv)
Execute 'adopt' command.
static int execTKbhit(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tkbhit subcommand.
void pushPrompt(const std::string &strPrompt)
Push prompt string onto stack of prompts.
virtual int compile()
Compile all added commands.
const int NoUid
Special values.
int numOfCmds() const
Get the total number of added commands.
User available command description structure.
static int execNameAnimal(const CmdExtArgVec &argv)
Execute 'name' command.
const char * m_sCommonName
command name
int uid() const
Get the argument's associated parsed command unique id.
AppCmdExec3 Command3s[]
The command descriptions.
static const char * AsciiAardvark[]
ASCII ardvaark.
static const char * AsciiAnt[]
ASCII ant.
std::ostream & backtrace(std::ostream &os, const bool bAll=false) const
Insert trace and error log backtrace into output stream.
const char * m_sScientificName
scientific name
const CmdDef & at(const int uid) const
Get the command definition with the unique id.
double m_fActDuration
activitiy uninterrupted duration
Command line interface class interface.
std::vector< CmdExtArg > CmdExtArgVec
vector of ext args type
static int run(CommandLine &cli)
Command line interface main loop.
virtual int addCommand(const CmdDesc &desc)
Add a command to the command line interface.
#define APP_EC_OK
success exit code
static int execSave(const CmdExtArgVec &argv)
Execute 'save' command.
int numOfRequiredArgs(int uid, int iform) const
Get the total number of required arguments.
static void mainInit(int argc, char *argv[])
Main initialization.
double now()
Get the current time, indentified by CLOCK_REALTIME, since the last Epoch.
static int loadCommands(CommandLine &cli)
Load commands into command line.
Activity m_eActivity
current activity
static const char * AsciiGrub[]
ASCII grub.
static const PkgInfo_T PkgInfo
static const char * AsciiCarrot[]
ASCII carrot.
static char * Argv0
the command
static int execTBt(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tbt subcommand.
static const char * AsciiVitamins[]
ASCII bottle of vitamins.
CommandLine Cli(CliName, CliPrompt)
the CLI
int addBtEnableCommand(CommandLine &cli, const std::string &strName="bt")
Add the core 'bt' command to the command-line interface.
static int execGetPetsState(const CmdExtArgVec &argv)
Execute 'get' command.
static int execCliTest(CommandLine &cli, const CmdExtArgVec &argv)
Execute command-line interface methods command.
size_t NumOfAnimals
number of animals
static int execTPrint(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tprint subcommand.
static int execTAdd(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tadd subcommand.
static AnimalInfo * findAnimal(const string &strCommonName)
Find the animal with the common name.
static int execTCompile(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tcompile subcommand.
Package version information.
static int execListAnimals(const CmdExtArgVec &argv)
Execute 'list' command.
int(* CmdExec3Func)(CommandLine &cli, const CmdExtArgVec &argv)
Command execution function type, variant 3.
double m_fActStart
activity start time
virtual int readCommand(int &uid, int &iform, str::StringVec &argv)
Read an input line from stdin and match to the best compiled command.
Command description and exectuion structure.
int addHelpCommand(CommandLine &cli, const std::string &strName="help")
Add the core 'help' command to the command-line interface.
CmdDesc m_desc
command description and syntax specification
bool ok() const
Test if command-line interface is ok to continue.
bool hasCmd(const int uid) const
Test if command exists.
int main(int argc, char *argv[])
Main.
#define PERROR(_err)
Error and warning printing macros.
static int execSleep(const CmdExtArgVec &argv)
Execute 'sleep' command.
static int execNamaste(const CmdExtArgVec &argv)
Execute 'namaste' command.
const std::string & getPrompt() const
Get the current prompt string.
const std::string & getName() const
Get command line interface's name.
static const char * AsciiNumbat[]
ASCII numbat.
static const char * AsciiMandrill[]
ASCII Mandrill.
static OptsPgmInfo_T PgmInfo
Program information.
static int execTPush(CommandLine &cli, const CmdExtArgVec &argv)
Execute clitest tpush subcommand.
const size_t NumOfCmds
Number of commands.
const string CliName("Adopt-An-Animal")
CLI name.
static int findCommand(const std::string &strName)
Find command by name.
string m_strGivenName
adopted given name by owner
const std::string & getErrorStr() const
Get the most recent error.
virtual void addToHistory(const str::StringVec &argv)
Add command to history.
CmdDesc m_desc
command description and syntax specification
static const char * AsciiWalking[][2]
ASCII walk sequence.
static void updateAnimals()
Update all animals' state data.
static int execReward(const CmdExtArgVec &argv)
Execute 'reward' command.
static int execFeedAnimal(const CmdExtArgVec &argv)
Execute 'feed' command.
int addQuitCommand(CommandLine &cli, const std::string &strName="quit")
Add the core 'quit' command to the command-line interface.