Skip to content

Commit

Permalink
Add --version option to gyoto command-line tool
Browse files Browse the repository at this point in the history
  • Loading branch information
paumard committed Dec 12, 2016
1 parent 340875e commit 1561f09
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bin/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I@top_srcdir@/include $(XERCES_CFLAGS) $(UDUNITS_CFLAGS) $(BOOST_CPPFLAGS)
AM_CPPFLAGS = -I@top_srcdir@/include $(XERCES_CFLAGS) $(UDUNITS_CFLAGS) $(BOOST_CPPFLAGS) \
-DPACKAGE_STRING="$(PACKAGE_STRING)"
AM_LDFLAGS = $(XERCES_LIBS) $(PTHREAD_LIBS) $(LDFLAGS_EXEC)
AM_CXXFLAGS = $(PTHREAD_CFLAGS) $(CXXFLAGS_EXEC)
CLEANFILES =
Expand Down
4 changes: 3 additions & 1 deletion bin/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I@top_srcdir@/include $(XERCES_CFLAGS) $(UDUNITS_CFLAGS) $(BOOST_CPPFLAGS)
AM_CPPFLAGS = -I@top_srcdir@/include $(XERCES_CFLAGS) $(UDUNITS_CFLAGS) $(BOOST_CPPFLAGS) \
-DPACKAGE_STRING="$(PACKAGE_STRING)"

AM_LDFLAGS = $(XERCES_LIBS) $(PTHREAD_LIBS) $(LDFLAGS_EXEC) \
$(am__append_3)
AM_CXXFLAGS = $(PTHREAD_CFLAGS) $(CXXFLAGS_EXEC)
Expand Down
21 changes: 14 additions & 7 deletions bin/gyoto.C
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ struct Gyoto::Arg: public option::Arg
};
enum optionType { DEBUG, QUIET, VERBOSE, SILENT,
IMIN, IMAX, JMIN, JMAX, ISTEP, JSTEP, ISPEC, JSPEC};
enum optionIndex { UNKNOWN, HELP, PLUGINS, LIST, VERBOSITY, NOSIGFPE, RANGE,
enum optionIndex { UNKNOWN, HELP, PLUGINS, LIST, VERSION, VERBOSITY, NOSIGFPE, RANGE,
BOUNDARIES, STEPS, IPCT, TIME, TMIN, FOV, RESOLUTION,
DISTANCE, PALN, INCLINATION, ARGUMENT, NTHREADS, NPROCESSES,
SETPARAMETER, UNIT, XMLWRITE};
const option::Descriptor usage[] =
{
{UNKNOWN, 0, "", "",option::Arg::None, "\nUSAGE: gyoto [options] input.xml output.fits\n\n"
"Generic options:\n -- \tStop option processing." },
{UNKNOWN, 0, "", "",option::Arg::None, "\nUSAGE: gyoto [options] input.xml output.fits\t\n\n"
"Generic options:\t\n -- \tStop option processing." },
{HELP, 0,"h","help",option::Arg::Optional, " --help[=<c>, -h<c> \tWithout argument, print usage and exit. With argument, document class <c> (e.g. \"Screen\", \"Astrobj::Star\") and exit." },
{VERSION, 0, "", "version", option::Arg::None, " --version, -V \tPrint the Gyoto version."},
{LIST, 0,"l","list",option::Arg::None, " --list, -l \tPrint the Gyoto register of Astrobj, Metrics etc." },
{NOSIGFPE, 0, "", "no-sigfpe",option::Arg::None, " --no-sigfpe \tDo not enable SIGFPE."
#if !defined HAVE_FENV_H
Expand Down Expand Up @@ -194,9 +195,12 @@ int main(int argc, char** argv) {
return 1;

// Check whether to output usage string
if ((!options[LIST] && (argc == 0 || parse.nonOptionsCount() != 2 || options[UNKNOWN])) || options[HELP] ) {
if (!options[HELP].arg) option::printUsage(std::cout, usage);
if (!options[LIST] && !options[HELP].arg) {
if (options[VERSION]
|| (!options[LIST] && (argc == 0 || parse.nonOptionsCount() != 2 || options[UNKNOWN])) || options[HELP] ) {
cout << GYOTO_STRINGIFY(PACKAGE_STRING) << endl
<< "ABI compatibility version: " << GYOTO_SOVERS << endl;
if (!options[VERSION] && !options[HELP].arg) option::printUsage(std::cout, usage);
if (!options[VERSION] && !options[LIST] && !options[HELP].arg) {
if (options[HELP]) return 0;
return 1;
}
Expand All @@ -223,7 +227,8 @@ int main(int argc, char** argv) {
if (parse.nonOptionsCount() > 1) pixfile=strdup(parse.nonOptions()[1]);

// State copyright
if (!options[LIST] && !options[HELP] && verbose() >= GYOTO_QUIET_VERBOSITY)
if (options[VERSION]
||(!options[LIST] && !options[HELP] && verbose() >= GYOTO_QUIET_VERBOSITY)) {
cout << " Copyright (c) 2011-2015 Frederic Vincent & Thibaut Paumard\n"
<< " GYOTO is distributed under the terms of the GPL v. 3 license.\n"
<< " We request that use of Gyoto in scientific publications be "
Expand All @@ -233,6 +238,8 @@ int main(int argc, char** argv) {
<< " Classical and Quantum Gravity 28, 225011 (2011) "
<< "[arXiv:1109.4769]"
<< endl << endl;
}
if (options[VERSION]) return 0;

if (options[PLUGINS])
pluglist = options[PLUGINS].last()->arg?options[PLUGINS].last()->arg:"";
Expand Down

0 comments on commit 1561f09

Please sign in to comment.