summaryrefslogtreecommitdiffstats
path: root/main.c
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-05-30 06:24:58 +0900
commit2df3c33d5d20074a4a9bc36253a788274c96bd4e (patch)
tree9991ab290f524ff72fc3eb98eda8adfb5f64f950 /main.c
parent94baac4cf34c57cc9bfe47cbc69a3e5de4058fba (diff)
downloadsubsurface-2df3c33d5d20074a4a9bc36253a788274c96bd4e.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>
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/main.c b/main.c
index 16d44d326..f02982289 100644
--- a/main.c
+++ b/main.c
@@ -87,27 +87,52 @@ const char *monthname(int mon)
*/
static gboolean imported = FALSE;
+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 */
process_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 */