summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc
new file mode 100644
index 0000000..9756c87
--- /dev/null
+++ b/src/main.cc
@@ -0,0 +1,47 @@
+#include "args.hh"
+#include "config.h"
+#include "image_processor.hh"
+#include "spawner.hh"
+
+#include <stdlib.h> // NOLINT(modernize-deprecated-headers)
+#include <iostream>
+#include <string_view>
+#include <vector>
+
+int main(int argc, char** argv) {
+ auto args = Args::create();
+ auto opt_help = args->option('h', "help", "display this text and exit");
+ auto opt_version = args->option('V', "version", "display version and exit");
+ std::vector<std::string_view> arguments;
+ if (!args->run(argc, argv, &arguments)) {
+ args->print_error(std::cerr);
+ std::cerr << "Try `sawmill --help` for usage.\n";
+ return EXIT_FAILURE;
+ }
+ if (opt_help->is_set()) {
+ std::cout << "Usage: `sawmill [OPTION]...`\n"
+ << "This is a window manager for Wayland.\n"
+ << "\n";
+ args->print_help(std::cout);
+ return EXIT_SUCCESS;
+ }
+ if (opt_version->is_set()) {
+ std::cout << "sawmill " << VERSION << " written by Joel Klinghed.\n";
+ return EXIT_SUCCESS;
+ }
+ auto spawner = Spawner::create();
+ if (spawner.has_value()) {
+ auto processor = spawner.value()->run(Spawner::Exec::kImageProcessor);
+ if (processor.has_value()) {
+ auto ret = image_processor::peek(**processor, "/home/the_jk/Downloads/image2vector.svg");
+ if (ret.has_value()) {
+ std::cout << ret->width << "x" << ret->height << '\n';
+ } else {
+ std::cerr << "Bad file\n";
+ }
+ return EXIT_SUCCESS;
+ }
+ }
+ std::cerr << "Unable to launch spawner.\n";
+ return EXIT_FAILURE;
+}