diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-01-02 22:42:31 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-01-02 22:42:31 +0100 |
| commit | 6ed8f5151719fbc14ec0ac6d28a346d1f74cf2ca (patch) | |
| tree | ebe7588e89e1aa2ae5376acf85f3a3a7b2ec7e10 /src/main.cc | |
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 47 |
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; +} |
