Commit 2cd19ab5 authored by Wescoeur's avatar Wescoeur

feat(src/app/cli/Cli): `mRegExpArgs` and `mRegExpFunctionName` are now static...

feat(src/app/cli/Cli): `mRegExpArgs` and `mRegExpFunctionName` are now static & `parseFunctionName` and `parseArgs` private
parent b97c1f48
...@@ -65,13 +65,16 @@ void Cli::Command::execute (const QHash<QString, QString> &args) { ...@@ -65,13 +65,16 @@ void Cli::Command::execute (const QHash<QString, QString> &args) {
// ============================================================================= // =============================================================================
Cli::Cli (QObject *parent) : QObject(parent) { // FIXME: Do not accept args without value like: cmd toto.
// FIXME: Do not accept args without value like: cmd toto. // In the future `toto` could be a boolean argument.
// In the future `toto` could be a boolean argument. QRegExp Cli::mRegExpArgs("(?:(?:(\\w+)\\s*)=\\s*(?:\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|([^\\s]+)\\s*))");
mRegExpArgs = QRegExp("(?:(?:(\\w+)\\s*)=\\s*(?:\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|([^\\s]+)\\s*))"); QRegExp Cli::mRegExpFunctionName("^\\s*(\\w+)\\s*");
mRegExpFunctionName = QRegExp("^\\s*(\\w+)\\s*");
makeCommands(); Cli::Cli (QObject *parent) : QObject(parent) {
addCommand("show", tr("showFunctionDescription"), cliShow);
addCommand("call", tr("showFunctionCall"), cliCall, {
{ "sip-address", {} }
});
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -83,13 +86,6 @@ void Cli::addCommand (const QString &functionName, const QString &description, F ...@@ -83,13 +86,6 @@ void Cli::addCommand (const QString &functionName, const QString &description, F
mCommands[functionName] = Cli::Command(functionName, description, function, argsScheme); mCommands[functionName] = Cli::Command(functionName, description, function, argsScheme);
} }
void Cli::makeCommands () noexcept {
addCommand("show", tr("showFunctionDescription"), cliShow);
addCommand("call", tr("showFunctionCall"), cliCall, {
{ "sip-address", {} }
});
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Cli::executeCommand (const QString &command) noexcept { void Cli::executeCommand (const QString &command) noexcept {
......
...@@ -71,16 +71,16 @@ public: ...@@ -71,16 +71,16 @@ public:
void executeCommand (const QString &command) noexcept; void executeCommand (const QString &command) noexcept;
const QString parseFunctionName (const QString &command) noexcept;
const QHash<QString, QString> parseArgs (const QString &command, const QString functionName, bool &soFarSoGood) noexcept;
private: private:
void addCommand (const QString &functionName, const QString &description, Function function, const QHash<QString, Argument> &argsScheme = {}) noexcept; void addCommand (const QString &functionName, const QString &description, Function function, const QHash<QString, Argument> &argsScheme = {}) noexcept;
void makeCommands () noexcept;
QRegExp mRegExpArgs; const QString parseFunctionName (const QString &command) noexcept;
QRegExp mRegExpFunctionName; const QHash<QString, QString> parseArgs (const QString &command, const QString functionName, bool &soFarSoGood) noexcept;
QHash<QString, Command> mCommands; QHash<QString, Command> mCommands;
static QRegExp mRegExpArgs;
static QRegExp mRegExpFunctionName;
}; };
#endif // CLI_H_ #endif // CLI_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment