commit 641cf947f92d3942498682a1f3ab8771468cce72
parent 4a347c1c17795d08c808eb7ed0424d0701c037d2
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 22 Sep 2019 15:18:34 +0200
Add the --version option
Diffstat:
4 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -38,7 +38,8 @@ include_directories(
${RSys_INCLUDE_DIR}
${Star3D_INCLUDE_DIR}
${StarSchiff_INCLUDE_DIR}
- ${StarSP_INCLUDE_DIR})
+ ${StarSP_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
include(rcmake)
@@ -52,6 +53,9 @@ set(VERSION_MINOR 4)
set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+configure_file(${SCHIFF_SOURCE_DIR}/schiff_version.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/schiff_version.h @ONLY)
+
set(SCHIFF_FILES_SRC
schiff.c
schiff_args.c
diff --git a/doc/schiff.1 b/doc/schiff.1
@@ -88,6 +88,9 @@ do not print the helper message when no \fIFILE\fR is submitted.
.TP
.B \-w \fIW0\fR[\fB:\fIW1\fR]...
list of wavelengths in vacuum (expressed in micron) to integrate.
+.TP
+.B \-\-version
+display version information and exit.
.SH EXAMPLES
Estimate the radiative properties of soft particles whose shape is described in
the \fBgeometry.yaml\fR file and its optical properties in the \fBproperties\fR
diff --git a/src/schiff_args.c b/src/schiff_args.c
@@ -17,6 +17,7 @@
#define _POSIX_C_SOURCE 2 /* getopt support */
#include "schiff_args.h"
+#include "schiff_version.h"
#include "schiff_optical_properties.h"
#include <rsys/dynamic_array_char.h>
@@ -90,7 +91,10 @@ print_help(const char* binary)
" -q do not print the helper message when no FILE is submitted.\n");
printf(
" -w A[:B]... list of wavelengths in vacuum (expressed in micron) to\n"
-" integrate.\n\n");
+" integrate.\n");
+ printf(
+" --version display version information and exit.\n");
+ printf("\n");
printf(
"Copyright (C) 2015, 2016 CNRS. Copyright (C) 2019 |Meso|Star>. This is free\n"
"software released under the GNU GPL license, version 3 or later. You are free\n"
@@ -1451,10 +1455,22 @@ schiff_args_init
{
int quiet = 0;
int opt;
+ int i;
res_T res = RES_OK;
ASSERT(argc && argv && args);
*args = SCHIFF_ARGS_NULL;
+
+ FOR_EACH(i, 1, argc) {
+ if(!strcmp(argv[i], "--version")) {
+ printf("Schiff %d.%d.%d\n",
+ SCHIFF_VERSION_MAJOR,
+ SCHIFF_VERSION_MINOR,
+ SCHIFF_VERSION_PATCH);
+ goto exit;
+ }
+ }
+
while((opt = getopt(argc, argv, "a:A:d:Dg:G:hi:l:n:o:qw:")) != -1) {
switch(opt) {
case 'a':
diff --git a/src/schiff_version.h.in b/src/schiff_version.h.in
@@ -0,0 +1,25 @@
+/* Copyright (C) 2015, 2016 CNRS
+ * Copyright (C) 2019 |Meso|Star>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SCHIFF_VERSION_H
+#define SCHIFF_VERSION_H
+
+#define SCHIFF_VERSION_MAJOR @VERSION_MAJOR@
+#define SCHIFF_VERSION_MINOR @VERSION_MINOR@
+#define SCHIFF_VERSION_PATCH @VERSION_PATCH@
+
+#endif /* SCHIFF_VERSION_H */
+