diff options
author | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-04-07 20:54:29 (GMT) |
---|---|---|
committer | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-04-07 20:54:29 (GMT) |
commit | c1fb612bad85ab74bdff9778deb9bea59ccf202e (patch) | |
tree | e1cad3d94df21b943b36b791c18dc2b290027c47 /src/openscad.cc | |
parent | c1fda19e259b12a4d43a935c8c1f76c8adb4bfe9 (diff) |
Added --help -h/-v --version options to commandline interface
git-svn-id: http://svn.clifford.at/openscad/trunk@514 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/openscad.cc')
-rw-r--r-- | src/openscad.cc | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/openscad.cc b/src/openscad.cc index f01d831..27935ac 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -56,6 +56,14 @@ static void help(const char *progname) exit(1); } +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +static void version() +{ + printf("openscad version %s\n",TOSTRING(OPENSCAD_VERSION)); + exit(1); +} + QString commandline_commands; const char *make_command = NULL; QSet<QString> dependencies; @@ -115,13 +123,37 @@ int main(int argc, char **argv) const char *off_output_file = NULL; const char *dxf_output_file = NULL; const char *deps_output_file = NULL; - + + static struct option long_options[] = + { + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + int option_index = 0; + int opt; - - while ((opt = getopt(argc, argv, "s:o:x:d:m:D:")) != -1) + while ((opt = getopt_long(argc, argv, "s:o:x:d:m:D:vh", long_options, &option_index)) != -1) { switch (opt) { + case 0: + switch (option_index) + { + case 'v': + version(); + break; + case 'h': + help(argv[0]); + break; + } + break; + case 'v': + version(); + break; + case 'h': + help(argv[0]); + break; case 's': if (stl_output_file || off_output_file || dxf_output_file) help(argv[0]); |