]> git.tue.mpg.de Git - paraslash.git/commitdiff
play: Print help text if no audio files are given.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 29 Dec 2017 14:08:15 +0000 (15:08 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 14 Jan 2018 21:23:24 +0000 (22:23 +0100)
This is more helpful than the lopsub error message. Since
handle_help_flags() already checked the arg count, the call to
lls_check_arg_count() can be removed.

play.c

diff --git a/play.c b/play.c
index bd94fcd9dedb8481185b79320919bce7ede63c70..78d53fa8c7659c55f375c1e15a30ca5ac7f88488 100644 (file)
--- a/play.c
+++ b/play.c
@@ -139,7 +139,7 @@ static void handle_help_flags(void)
 
        if (OPT_GIVEN(DETAILED_HELP))
                help = lls_long_help(CMD_PTR);
-       else if (OPT_GIVEN(HELP))
+       else if (OPT_GIVEN(HELP) || lls_num_inputs(play_lpr) == 0)
                help = lls_short_help(CMD_PTR);
        else
                return;
@@ -163,7 +163,7 @@ static void parse_config_or_die(int argc, char *argv[])
                goto fail;
        loglevel = OPT_UINT32_VAL(LOGLEVEL);
        version_handle_flag("play", OPT_GIVEN(VERSION));
-       handle_help_flags();
+       handle_help_flags(); /* also handles the zero-arg case */
        if (OPT_GIVEN(CONFIG_FILE))
                cf = para_strdup(OPT_STRING_VAL(CONFIG_FILE));
        else {
@@ -178,7 +178,7 @@ static void parse_config_or_die(int argc, char *argv[])
                if (ret == -ERRNO_TO_PARA_ERROR(ENOENT) && OPT_GIVEN(CONFIG_FILE))
                        goto free_cf;
                ret = 0;
-               goto check_arg_count;
+               goto setup_keymap;
        }
        ret = lls(lls_convert_config(map, sz, NULL, &cf_argv, &errctx));
        para_munmap(map, sz);
@@ -196,10 +196,7 @@ static void parse_config_or_die(int argc, char *argv[])
        lls_free_parse_result(play_lpr, cmd);
        play_lpr = merged_lpr;
        loglevel = OPT_UINT32_VAL(LOGLEVEL);
-check_arg_count:
-       ret = lls(lls_check_arg_count(play_lpr, 1, INT_MAX, &errctx));
-       if (ret < 0)
-               goto free_cf;
+setup_keymap:
        num_kmas = OPT_GIVEN(KEY_MAP);
        for (i = 0; i < num_kmas; i++) {
                const char *kma = lls_string_val(i, OPT_RESULT(KEY_MAP));