Skip to content

Commit 4bf9877

Browse files
committed
Add -v parameter to print version
Add support for POSIX --version and --help
1 parent e8bba8c commit 4bf9877

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

therionsurface2survex.cxx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ struct datapoint_f {
5353
};
5454

5555

56+
/* Print version */
57+
void version() {
58+
cout << PROGNAME << " Version " << VERSION << ", License GPLv3" <<endl;
59+
}
60+
5661
/* Print usage info */
5762
void usage () {
58-
cout << PROGNAME << " Version " << VERSION << ", License GPLv3" <<endl;
63+
version();
5964
cout << "Convert therion surface meshes to survex" << endl;
6065
cout << "Usage: [-hsdt] [-o outfile] [-i infile] -- [infile]"<<endl;
6166
cout << " -o outfile File to write to. Will be derived from infile if not specified."<<endl;
@@ -81,15 +86,25 @@ int main (int argc, char **argv)
8186
int index;
8287
int c;
8388

89+
// support standard POSIX options
90+
for (int i=0; i<argc; i++) {
91+
if (NULL != strstr(argv[i],"--version")) { version(); return 0; }
92+
if (NULL != strstr(argv[i],"--help")) { usage(); return 0; }
93+
}
94+
8495
opterr = 0;
8596

86-
while ((c = getopt (argc, argv, "hstdi:o:")) != -1)
97+
while ((c = getopt (argc, argv, "vhstdi:o:")) != -1)
8798
switch (c)
8899
{
89100
case 'h':
90101
usage();
91102
return 0;
92103
break;
104+
case 'v':
105+
version();
106+
return 0;
107+
break;
93108
case 'i':
94109
inFile = optarg;
95110
break;

0 commit comments

Comments
 (0)