![]() |
appkit
1.5.1
RoadNarrows Robotics Application Kit
|
Command line interface example program. More...
#include <fcntl.h>#include <unistd.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <iostream>#include <fstream>#include <sstream>#include <string>#include <map>#include "rnr/rnrconfig.h"#include "rnr/log.h"#include "rnr/opts.h"#include "rnr/pkg.h"#include "rnr/appkit/Time.h"#include "rnr/appkit/CmdExtArg.h"#include "rnr/appkit/CommandLine.h"#include "rnr/appkit/CmdAddOns.h"#include "version.h"Go to the source code of this file.
Classes | |
| struct | AnimalInfo |
| struct | AppCmdExec |
| Command description and exectuion structure. More... | |
| struct | AppCmdExec3 |
| Self-Reference command description and exectuion structure. More... | |
Macros | |
| #define | APP_EC_OK 0 |
| success exit code | |
| #define | APP_EC_ARGS 2 |
| command-line options/arguments error exit code | |
| #define | APP_EC_EXEC 4 |
| execution exit code | |
Enumerations | |
| enum | Activity { ActIdle, ActSleeping, ActEating, ActWalking } |
| Animal activities. More... | |
Functions | |
| static ostream & | operator<< (ostream &os, const char *art[]) |
| ASCII art output stream operator. More... | |
| 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. More... | |
| static AnimalInfo * | findAnimal (const string &strCommonName) |
| Find the animal with the common name. More... | |
| const string | CliName ("Adopt-An-Animal") |
| CLI name. | |
| const string | CliPrompt ("aaa> ") |
| CLI prompt. | |
Variables | |
| static char * | Argv0 |
| the command | |
| static OptsPgmInfo_T | PgmInfo |
| Program information. More... | |
| static OptsInfo_T | OptsInfo [] |
| Command line options information. More... | |
| static const char * | AsciiAardvark [] |
| ASCII ardvaark. More... | |
| static const char * | AsciiMandrill [] |
| ASCII Mandrill. More... | |
| static const char * | AsciiNumbat [] |
| ASCII numbat. More... | |
| static const char * | AsciiZebraSmall [] |
| ASCII small zebra. More... | |
| static const char * | AsciiZebra [] |
| ASCII zebra. More... | |
| static const char * | AsciiAnt [] |
| ASCII ant. More... | |
| static const char * | AsciiGrub [] |
| ASCII grub. More... | |
| static const char * | AsciiCarrot [] |
| ASCII carrot. More... | |
| static const char * | AsciiVitamins [] |
| ASCII bottle of vitamins. More... | |
| static const char * | AsciiWalking [][2] |
| ASCII walk sequence. More... | |
| const char * | NoName = "No given name" |
| 'no name' name | |
| AnimalInfo | Animals [] |
| The animals. More... | |
| size_t | NumOfAnimals = arraysize(Animals) |
| number of animals | |
| Time | ActivityTime |
| activity time | |
| CommandLine | Cli (CliName, CliPrompt) |
| the CLI | |
| #define | PERROR(_err) cout << CliName << ": " << "Error: " << _err << endl |
| Error and warning printing macros. | |
| #define | PWARN(_warn) cout << CliName << ": " << _warn << endl |
| #define | PCMDERROR(_cmd, _err) cout << CliName << ": " << _cmd << ": " << "Error: " << _err << endl |
| #define | PCMDWARN(_cmd, _warn) cout << CliName << ": " << _cmd << ": " << _warn << endl |
| AppCmdExec | Commands [] |
| The command descriptions. | |
| const size_t | NumOfCmds = arraysize(Commands) |
| Number of commands. | |
| static const char * | CliTestCmdName = "clitest" |
| AppCmdExec3 | Command3s [] |
| The command descriptions. More... | |
| const size_t | NumOfCmd3s = arraysize(Command3s) |
| Number of commands. | |
| int | checkCmd (const CmdExtArg &argv0, int argc, const string strTgtName="") |
| Check if command input is matched correctly with the command execution. More... | |
| static int | execAdopt (const CmdExtArgVec &argv) |
| Execute 'adopt' command. More... | |
| static int | execSleep (const CmdExtArgVec &argv) |
| Execute 'sleep' command. More... | |
| static int | execNameAnimal (const CmdExtArgVec &argv) |
| Execute 'name' command. More... | |
| static int | execNamaste (const CmdExtArgVec &argv) |
| Execute 'namaste' command. More... | |
| static int | execFeedAnimal (const CmdExtArgVec &argv) |
| Execute 'feed' command. More... | |
| static int | execWalkAnimal (const CmdExtArgVec &argv) |
| Execute 'walk' command. More... | |
| static int | execListAnimals (const CmdExtArgVec &argv) |
| Execute 'list' command. More... | |
| static int | execGetPetsState (const CmdExtArgVec &argv) |
| Execute 'get' command. More... | |
| static int | execReward (const CmdExtArgVec &argv) |
| Execute 'reward' command. More... | |
| static int | execSave (const CmdExtArgVec &argv) |
| Execute 'save' command. More... | |
| static int | findCommand (const std::string &strName) |
| Find command by name. More... | |
| static int | execTAdd (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tadd subcommand. More... | |
| static int | execTBt (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tbt subcommand. More... | |
| static int | execTCompile (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tcompile subcommand. More... | |
| static int | execTDump (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tdump subcommand. More... | |
| static int | execTKbhit (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tkbhit subcommand. More... | |
| static int | execTPrint (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tprint subcommand. More... | |
| static int | execTPush (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tpush subcommand. More... | |
| static int | execTRemove (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tremove subcommand. More... | |
| static int | execCliTest (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute command-line interface methods command. More... | |
| static void | mainInit (int argc, char *argv[]) |
| Main initialization. More... | |
| static void | updateAnimals () |
| Update all animals' state data. | |
| static int | loadCommands (CommandLine &cli) |
| Load commands into command line. More... | |
| static int | run (CommandLine &cli) |
| Command line interface main loop. More... | |
| int | main (int argc, char *argv[]) |
| Main. More... | |
Command line interface example program.
Demonstrates the usage of librnr_appkit's CommandLine, ReadLine, and LogBook classes to build a command line interface.
Definition in file rnr_eg_cli.cxx.