1 /*
2 Copyright (c) 2013-2014 Timur Gafarov 
3 
4 Boost Software License - Version 1.0 - August 17th, 2003
5 
6 Permission is hereby granted, free of charge, to any person or organization
7 obtaining a copy of the software and accompanying documentation covered by
8 this license (the "Software") to use, reproduce, display, distribute,
9 execute, and transmit the Software, and to prepare derivative works of the
10 Software, and to permit third-parties to whom the Software is furnished to
11 do so, all subject to the following:
12 
13 The copyright notices in the Software and this entire statement, including
14 the above license grant, this restriction and the following disclaimer,
15 must be included in all copies of the Software, in whole or in part, and
16 all derivative works of the Software, unless such copies or derivative
17 works are solely in the form of machine-executable object code generated by
18 a source language processor.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
23 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
24 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 DEALINGS IN THE SOFTWARE.
27 */
28 
29 module cmdopt;
30 
31 import std.stdio;
32 import std.getopt;
33 import std.process;
34 import core.stdc.stdlib;
35 
36 class CmdOptions
37 {
38     bool help = false;
39     bool emulate = false;
40     bool quiet = false;
41     bool rebuild = false;
42     bool nocache = false;
43     bool lib = false;
44     bool release = false;
45     bool noconsole = false;
46     bool strip = false;
47     bool clean = false;
48     bool run = false;
49     bool _debug_ = false;
50     bool nobacktrace = false;
51     bool https = false;
52     bool rsp = false;
53     bool local = false;
54 
55     string output;
56     string cache;
57     string rc;
58     string cflags;
59     string lflags;
60     string conf;
61     string s;
62 
63     string dump;
64 
65     string program;
66     string[] targets;
67 
68     this(string[] args)
69     {
70         try{ getopt(
71           args,
72           "help|h",    &help,
73           "emulate|e", &emulate,
74           "quiet|q",   &quiet,
75           "rebuild|r", &rebuild,
76           "nocache",   &nocache,
77           "lib",       &lib,
78           "release",   &release,
79           "noconsole", &noconsole,
80           "strip",     &strip,
81           "output|o",  &output,
82           "clean",     &clean,
83           "cache",     &cache,
84           "rc",        &rc,
85           "cflags|c",  &cflags,
86           "lflags|l",  &lflags,
87           "run",       &run,
88           "dc",        &conf,
89           "conf",      &conf,
90           "debug",     &_debug_,
91           "nobacktrace", &nobacktrace,
92           "s",         &s,
93           "dump",      &dump,
94           "https",     &https,
95           "rsp",       &rsp,
96           "local",     &local
97         );}
98         catch(Exception)
99         {
100             writeln("Illegal option");
101             core.stdc.stdlib.exit(1);
102         }
103 
104         program = args[0];
105         targets = args[1..$];
106     }
107 }
108