Skip to content

Commit

Permalink
Add -v parameter to print version
Browse files Browse the repository at this point in the history
Add support for POSIX --version and --help
  • Loading branch information
hbeni committed Feb 24, 2021
1 parent e8bba8c commit 4bf9877
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions therionsurface2survex.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ struct datapoint_f {
};


/* Print version */
void version() {
cout << PROGNAME << " Version " << VERSION << ", License GPLv3" <<endl;
}

/* Print usage info */
void usage () {
cout << PROGNAME << " Version " << VERSION << ", License GPLv3" <<endl;
version();
cout << "Convert therion surface meshes to survex" << endl;
cout << "Usage: [-hsdt] [-o outfile] [-i infile] -- [infile]"<<endl;
cout << " -o outfile File to write to. Will be derived from infile if not specified."<<endl;
Expand All @@ -81,15 +86,25 @@ int main (int argc, char **argv)
int index;
int c;

// support standard POSIX options
for (int i=0; i<argc; i++) {
if (NULL != strstr(argv[i],"--version")) { version(); return 0; }
if (NULL != strstr(argv[i],"--help")) { usage(); return 0; }
}

opterr = 0;

while ((c = getopt (argc, argv, "hstdi:o:")) != -1)
while ((c = getopt (argc, argv, "vhstdi:o:")) != -1)
switch (c)
{
case 'h':
usage();
return 0;
break;
case 'v':
version();
return 0;
break;
case 'i':
inFile = optarg;
break;
Expand Down

0 comments on commit 4bf9877

Please sign in to comment.