diff options
author | Chris Wilson <chris+github@qwirx.com> | 2010-02-25 23:20:27 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2010-02-25 23:20:27 +0000 |
commit | 27ab8a2537deaff65a9bb68b2a03bb267361e91f (patch) | |
tree | 2225f568915e1d1dac8e9fb1cb0f51d127a88f9b /bin/bbackupquery/BackupQueries.cpp | |
parent | 25203d94333f492a928278b1abb8642302242502 (diff) |
First attempt at tab completion for readline/libedit in bbackupquery,
with commands and local file names, because it's easy and will help to
find compatibility problems.
Diffstat (limited to 'bin/bbackupquery/BackupQueries.cpp')
-rw-r--r-- | bin/bbackupquery/BackupQueries.cpp | 76 |
1 files changed, 25 insertions, 51 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index f799ab43..2a99c077 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -63,6 +63,30 @@ #define COMPARE_RETURN_ERROR 3 #define COMMAND_RETURN_ERROR 4 +// Data about commands +QueryCommandSpecification commands[] = +{ + { "quit", "" }, + { "exit", "" }, + { "list", "rodIFtTash", }, + { "pwd", "" }, + { "cd", "od" }, + { "lcd", "" }, + { "sh", "" }, + { "getobject", "" }, + { "get", "i" }, + { "compare", "alcqAEQ" }, + { "restore", "drif" }, + { "help", "" }, + { "usage", "m" }, + { "undelete", "" }, + { "delete", "" }, + { NULL, NULL } +}; + +const char *alias[] = {"ls", 0}; +const int aliasIs[] = {Command_List, 0}; + // -------------------------------------------------------------------------- // // Function @@ -100,12 +124,6 @@ BackupQueries::~BackupQueries() { } -typedef struct -{ - const char* name; - const char* opts; -} QueryCommandSpecification; - // -------------------------------------------------------------------------- // // Function @@ -206,51 +224,7 @@ void BackupQueries::DoCommand(const char *Command, bool isFromCommandLine) // blank command return; } - - // Data about commands - static QueryCommandSpecification commands[] = - { - { "quit", "" }, - { "exit", "" }, - { "list", "rodIFtTash", }, - { "pwd", "" }, - { "cd", "od" }, - { "lcd", "" }, - { "sh", "" }, - { "getobject", "" }, - { "get", "i" }, - { "compare", "alcqAEQ" }, - { "restore", "drif" }, - { "help", "" }, - { "usage", "m" }, - { "undelete", "" }, - { "delete", "" }, - { NULL, NULL } - }; - - typedef enum - { - Command_Quit = 0, - Command_Exit, - Command_List, - Command_pwd, - Command_cd, - Command_lcd, - Command_sh, - Command_GetObject, - Command_Get, - Command_Compare, - Command_Restore, - Command_Help, - Command_Usage, - Command_Undelete, - Command_Delete, - } - CommandType; - - static const char *alias[] = {"ls", 0}; - static const int aliasIs[] = {Command_List, 0}; - + // Work out which command it is... int cmd = 0; while(commands[cmd].name != 0 && ::strcmp(cmdElements[0].c_str(), commands[cmd].name) != 0) |