summaryrefslogtreecommitdiff
path: root/src/main.cc
blob: a1c8cd5e8ef03a59cb5391bedd6c7ab5a4fcbc00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "args.hh"
#include "config.h"

#include <iostream>

#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.\n";
    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);
    return 0;
  }
  if (opt_version->is_set()) {
    std::cout << "jkc " << VERSION
              << " written by Joel Klinghed <the_jk@spawned.biz>.\n";
    return 0;
  }
  return 0;
}