aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Henrik Brautaset Aronsen <subsurface@henrik.synth.no>2013-05-29 13:50:38 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-21 08:34:37 -0700
commitf9fafb397afe83724c586cf8ae0f364b60e892ac (patch)
treec119cf073c6446c74ea8ac664c5fb72d3ae89e00
parent58697c0289deffb58e702e4a3f8483073400bde0 (diff)
downloadsubsurface-f9fafb397afe83724c586cf8ae0f364b60e892ac.tar.gz
Add --help command line option
Added a simple usage text on the command line. Also added a --verbose alias for completeness. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--main.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/main.c b/main.c
index 6ad9eccf7..f6b42482f 100644
--- a/main.c
+++ b/main.c
@@ -9,7 +9,7 @@
#include "dive.h"
#include "divelist.h"
-#include "libdivecomputer.h"
+#include <libdivecomputer/version.h>
#include "version.h"
#include <osm-gps-map.h>
@@ -210,27 +210,52 @@ void report_dives(gboolean is_imported, gboolean prefer_imported)
dive_list_update_dives();
}
+static void print_version() {
+ printf("Subsurface v%s, ", VERSION_STRING);
+ printf("built with libdivecomputer v%s\n", dc_version(NULL));
+}
+
+static void print_help() {
+ print_version();
+ printf("\nUsage: subsurface [options] [logfile ...] [--import logfile ...]");
+ printf("\n\noptions include:");
+ printf("\n --help|-h This help text");
+ printf("\n --import logfile ... Logs before this option is treated as base, everything after is imported");
+ printf("\n --verbose|-v Verbose debug (repeat to increase verbosity)");
+ printf("\n --version Prints current version\n\n");
+}
+
static void parse_argument(const char *arg)
{
const char *p = arg+1;
do {
switch (*p) {
+ case 'h':
+ print_help();
+ exit(0);
case 'v':
verbose++;
continue;
case '-':
/* long options with -- */
- if (strcmp(arg,"--import") == 0) {
+ if (strcmp(arg, "--help") == 0) {
+ print_help();
+ exit(0);
+ }
+ if (strcmp(arg, "--import") == 0) {
/* mark the dives so far as the base,
* everything after is imported */
report_dives(FALSE, FALSE);
imported = TRUE;
return;
}
+ if (strcmp(arg, "--verbose") == 0) {
+ verbose++;
+ return;
+ }
if (strcmp(arg, "--version") == 0) {
- printf("Subsurface v%s, ", VERSION_STRING);
- printf("built with libdivecomputer v%s\n", dc_version(NULL));
+ print_version();
exit(0);
}
/* fallthrough */