Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GeneralCommands.hxx
Go to the documentation of this file.
1
34#ifndef _CONSOLE_GENERALCOMMANDS_HXX_
35#define _CONSOLE_GENERALCOMMANDS_HXX_
36
37#include "console/Console.hxx"
38
40extern const char *REVISIONS[];
41
47{
48public:
52 {
53 console->add_command("version", version_command);
54 }
55
56private:
63 static Console::CommandStatus version_command(FILE *fp, int argc,
64 const char *argv[],
65 void *context)
66 {
67 if (argc == 0)
68 {
69 fprintf(fp, "print all compiler and repository revisions\n");
71 }
72
73 if (REVISIONS[0] == nullptr)
74 {
75 fprintf(fp, "%s: No revision history\n", argv[0]);
76 }
77
78 for (int i = 0; REVISIONS[i] != nullptr; ++i)
79 {
80 fprintf(fp, "%s\n", REVISIONS[i]);
81 }
82
84 }
85
87};
88
89#endif // _CONSOLE_GENERALCOMMANDS_HXX_
const char * REVISIONS[]
Revision information.
This class provides a console available from stdin/stdout as well as via telnet.
Definition Console.hxx:68
void add_command(const char *name, Callback callback, void *context=NULL)
Add a new command to the console.
Definition Console.cxx:94
CommandStatus
Enumeration of recognized command callback results.
Definition Console.hxx:80
@ COMMAND_OK
Command executed successfully.
Definition Console.hxx:81
Container for all the general commands.
static Console::CommandStatus version_command(FILE *fp, int argc, const char *argv[], void *context)
Concatinate files.
GeneralCommands(Console *console)
Constructor.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171