From 1ed1159468602c649f170713eaea08f47f69c23f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 28 Jun 2020 00:11:16 +0200 Subject: Output error when wrong flag is passed to quickmedia --- src/QuickMedia.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index aba9485..881f2d6 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -112,7 +112,7 @@ namespace QuickMedia { fprintf(stderr, "EXAMPLES:\n"); fprintf(stderr, "QuickMedia manganelo\n"); fprintf(stderr, "QuickMedia youtube --tor\n"); - fprintf(stderr, "echo \"hello\nworld\" | QuickMedia dmenu\n"); + fprintf(stderr, "echo \"hello\\nworld\" | QuickMedia dmenu\n"); } static bool is_program_executable_by_name(const char *name) { @@ -165,6 +165,10 @@ namespace QuickMedia { plugin_logo_path = resources_root + "images/4chan_logo.png"; } else if(strcmp(argv[i], "dmenu") == 0) { current_plugin = new Dmenu(); + } else { + fprintf(stderr, "Invalid plugin %s\n", argv[i]); + usage(); + return -1; } } @@ -172,14 +176,13 @@ namespace QuickMedia { use_tor = true; } else if(strcmp(argv[i], "--use-system-mpv-config") == 0) { use_system_mpv_config = true; + } else if(argv[i][0] == '-') { + fprintf(stderr, "Invalid option %s\n", argv[i]); + usage(); + return -1; } } - if(!current_plugin) { - usage(); - return -1; - } - if(use_tor && !is_program_executable_by_name("torsocks")) { fprintf(stderr, "torsocks needs to be installed (and accessible from PATH environment variable) when using the --tor option\n"); return -2; -- cgit v1.2.3