summaryrefslogtreecommitdiff
path: root/src/options.c
blob: c4eb8d4b632768348f6329179da0ea7d1c5b5fa6 (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
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <unistd.h>

#include "options.h"
#include "logging.h"

static void print_usage(const char *progname)
{
   printf("Usage: %s [-c config_file] [-i input_directory] [-o output_directory]\n",
	  progname);	  
}

int parse_options(struct argent_options *opts, int argc, char **argv)
{
   opts->log_level = 0;
   opts->conf_filename = "argent.lua";
   opts->output_dir = "public";
   
   int opt;
   while ((opt = getopt(argc, argv, "vc:o:")) != -1) {
      switch (opt) {
      case 'v':
	 opts->log_level += 1;
	 break;
	 
      case 'c':
	 opts->conf_filename = optarg;
	 break;

      case 'o':
	 opts->output_dir = optarg;
	 break;

      default:
	 print_usage(argv[0]);
	 return 1;
      }
   }

   // ew, globals (sorry)
   argent_log_level = opts->log_level;

   return 0;
}