From d75b25d50f4df655d1e69ff900cfeee823039296 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 3 Sep 2025 00:49:27 +0200 Subject: Initial commit Only a basic argument parser to start with. --- src/main.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main.cc (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..9abed21 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,33 @@ +#include + +#include "args.hh" +#include "config.h" + +#ifndef VERSION +# define VERSION "unknown" +#endif + +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."); + if (!args->run(argc, argv)) { + args->print_error(std::cerr); + std::cerr << "Try 'jkc --help' for more information." << std::endl; + return 1; + } + if (opt_help->is_set()) { + std::cout << "Usage: jkc [OPTION...] SOURCE...\n" + << "Java and Kotlin Compiler\n" + << "\n"; + args->print_help(std::cout); + std::cout << std::flush; + return 0; + } + if (opt_version->is_set()) { + std::cout << "jkc " << VERSION + << " written by Joel Klinghed ." << std::endl; + return 0; + } + return 0; +} -- cgit v1.3