command 'feed' moved from ebusctl into ebusfeed;tools directory created.

This commit is contained in:
Roland Jax
2014-11-24 15:52:31 +01:00
parent b07a6930fd
commit 972277d68d
9 changed files with 255 additions and 152 deletions
+13 -7
View File
@@ -24,9 +24,9 @@
using namespace std;
Appl& Appl::Instance(const bool command)
Appl& Appl::Instance(const bool command, const bool argument)
{
static Appl instance(command);
static Appl instance(command, argument);
return instance;
}
@@ -114,10 +114,13 @@ void Appl::parseArgs(int argc, char* argv[])
i++;
continue;
}
m_arguments.push_back(_argv[i]);
if (m_command.size() == 0)
m_command = _argv[i];
else
m_arguments.push_back(_argv[i]);
}
if (m_arguments.size() == 0) {
if (m_command.size() == 0) {
cerr << endl << "command needed" << endl;
printHelp();
}
@@ -130,7 +133,7 @@ bool Appl::checkOption(const string& option, const string& value)
if (strcmp(option.c_str(), "settings") == 0)
printSettings();
if (strcmp(option.c_str(), "v") == 0 || strcmp(option.c_str(), "version") == 0)
if (strcmp(option.c_str(), "version") == 0)
printVersion();
if (strcmp(option.c_str(), "h") == 0 || strcmp(option.c_str(), "help") == 0)
@@ -194,7 +197,10 @@ void Appl::printHelp()
<< m_argv[0].substr(m_argv[0].find_last_of("/\\") + 1) << " [OPTIONS...]" ;
if (m_needCommand == true)
cerr << " COMMAND {ARGS...}" << endl << endl;
if (m_withArgument == true)
cerr << " COMMAND {ARGS...}" << endl << endl;
else
cerr << " COMMAND" << endl << endl;
else
cerr << endl << endl;
@@ -210,7 +216,7 @@ void Appl::printHelp()
}
}
cerr << " | --settings\n-v | --version\n-h | --help" << endl << endl;
cerr << endl << " | --settings\n | --version\n-h | --help" << endl << endl;
exit(EXIT_SUCCESS);
}
+38 -5
View File
@@ -117,9 +117,10 @@ public:
/**
* @brief create an instance and return the reference.
* @param command is true if an command is needed.
* @param argument is true if command could have an argument.
* @return the reference to instance.
*/
static Appl& Instance(const bool command=false);
static Appl& Instance(const bool command=false, const bool argument=false);
/**
* @brief destructor.
@@ -176,24 +177,50 @@ public:
int numArgs() const { return m_arguments.size(); }
/**
* @brief returns the string of an interested argument (0 = command).
* @brief returns the string of given command.
* @return the command string.
*/
string getCommand() const { return m_command; }
/**
* @brief returns the string of an interested argument.
* @param num number of interested argument.
* @return string value.
* @return the argument string.
*/
string getArg(const int num) const { return m_arguments[num]; }
private:
/** private constructor - singleton pattern */
Appl(const bool command) : m_needCommand(command) {}
/**
* @brief private construtor.
* @param command is true if an command is needed.
* @param argument is true if command could have an argument.
*/
Appl(const bool command, const bool argument)
: m_needCommand(command), m_withArgument(argument) {}
/**
* @brief private copy construtor.
* @param reference to an instance.
*/
Appl(const Appl&);
/**
* @brief private = operator.
* @param reference to an instance.
*/
Appl& operator=(const Appl&);
/** application options */
vector<opt_t> m_opts;
/** application options iterator */
vector<opt_t>::const_iterator o_it;
/** map option - value */
map<const char*, OptVal> m_optvals;
/** map option - value iterator */
map<const char*, OptVal>::iterator ov_it;
/** given arguments */
@@ -205,7 +232,13 @@ private:
/** true if the application need a command */
bool m_needCommand;
/** arguments (argument 0 = command) string */
/** true if the needed command could have an argument */
bool m_withArgument;
/** command (argument 0 = command) string */
string m_command;
/** arguments (argument >= 1) string */
vector<string> m_arguments;
/**