aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorEvsyukov Denis Anatolyevich <[email protected]>2020-01-09 15:16:04 +0300
committerEvsyukov Denis Anatolyevich <[email protected]>2020-01-09 15:16:04 +0300
commit5f00b5e188ab15381dda42a116a6a1689aa24d20 (patch)
treeac23f89197478818a462979b64d6195a7683ab9c /src/main.cpp
downloadt-5f00b5e188ab15381dda42a116a6a1689aa24d20.tar.xz
t-5f00b5e188ab15381dda42a116a6a1689aa24d20.zip
First commit
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..be82bf1
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,56 @@
+#include <iostream>
+#include <string>
+#include <filesystem>
+
+#include "cxxopts.hpp"
+#include "functions.hpp"
+
+using namespace std;
+
+int main(int argc, char *argv[]) {
+ cxxopts::Options options("MyProgram", "One line description of MyProgram");
+ options
+ .allow_unrecognised_options()
+ .add_options()
+ ("positional",
+ "Positional arguments: these are the arguments that are entered "
+ "without an option", cxxopts::value<std::vector<std::string>>())
+ ("e,edit", "edit TASK to contain TEXT", cxxopts::value<std::string>())
+ ("f,finish", "mark TASK as finished", cxxopts::value<std::string>())
+ ("r,remove", "Remove TASK from list", cxxopts::value<std::string>())
+ ("l,list", "work on LIST", cxxopts::value<std::string>())
+ ("t,taskdir", "work on the lists in DIR", cxxopts::value<std::string>())
+ ("d,delete-if-empty", "delete the task file if it becomes empty")
+ ("g,grep", "print only tasks that contain WORD", cxxopts::value<std::string>())
+ ("v,verbose", "print more detailed output (full task ids, etc)")
+ ("q,quiet", "print less detailed output (no task ids, etc)")
+ ("D,done", "list done tasks instead of unfinished ones")
+ ("h,help", "HELP");
+ options.parse_positional({"positional"});
+ auto result = options.parse(argc, argv);
+ const auto &arguments = result.arguments();
+ if (result.count("help")) {
+ std::cout << options.help() << std::endl;
+ exit(0);
+ }
+ if (result.count("positional")) {
+ std::cout << "Positional = {" << std::endl;
+ std::string str;
+ auto &v = result["positional"].as<std::vector<std::string>>();
+ for (const auto &s : v) {
+ str += s + " ";
+ }
+ std::cout << "\"" << trim(str) << "\"" << std::endl << "}" << std::endl;
+ }
+ std::string taskdir;
+ if (result.count("taskdir")) {
+ taskdir = result["taskdir"].as<std::string>();
+ } else {
+ namespace fs = std::filesystem;
+ taskdir=fs::current_path();
+ }
+
+ std::cout << "Current path is " << taskdir << '\n';
+ std::cout << "Saw " << arguments.size() << " arguments" << std::endl;
+ return 0;
+} \ No newline at end of file