From ff0a4ecfbeea3cacb4178cac2641afdef0c0d30f Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 22 Sep 2019 16:13:13 +0200 Subject: [PATCH] list command current state --- cli/commandlist.cpp | 33 +++++++++++++++++++++++++++++++++ cli/commandlist.h | 14 ++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 cli/commandlist.cpp create mode 100644 cli/commandlist.h diff --git a/cli/commandlist.cpp b/cli/commandlist.cpp new file mode 100644 index 0000000..e113af7 --- /dev/null +++ b/cli/commandlist.cpp @@ -0,0 +1,33 @@ +#include +#include "commandlist.h" +#include "databasefactory.h" +#include "logger.h" + +int CommandList::handle(QStringList arguments) +{ + QCommandLineParser parser; + parser.addOptions({ + {{"r", "reverse"}, "Print most-recent changed files first"}, + {{"c", "count"}, "Counts the number of paths listed"}, + {"pattern", "Only list files from index matching the pattern, e. g. */.git/*", "pattern"}, + }); + + parser.addHelpOption(); + parser.addPositionalArgument("list", "Lists paths in the index", "list [options]"); + + parser.process(arguments); + bool reverse = parser.isSet("reverse"); + if(reverse) + { + throw QSSGeneralException("Reverse option to be implemented"); + } + + QStringList files = parser.positionalArguments(); + QString queryStrings = files.join(' '); + auto results = dbService->search(QSSQuery::build(queryStrings)); + + for(SearchResult &result : results) + { + Logger::info() << result.fileData.absPath << endl; + } +} diff --git a/cli/commandlist.h b/cli/commandlist.h new file mode 100644 index 0000000..cc85456 --- /dev/null +++ b/cli/commandlist.h @@ -0,0 +1,14 @@ +#ifndef COMMANDSEARCH_H +#define COMMANDSEARCH_H +#include "command.h" +#include "../shared/sqlitesearch.h" + +class CommandList : public Command +{ + public: + using Command::Command; + + int handle(QStringList arguments) override; +}; + +#endif // COMMANDSEARCH_H