diff --git a/src/cli.c b/src/cli.c index 8d193e4..4578c6e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1,33 +1,56 @@ + #include "app/cli.h" +#include "config.h" #include #include #include #include void print_usage(const char *program_name) { - printf("KeyVibe - Mechanical Keyboard Sound Simulator\n\n"); - printf("Usage: %s [OPTIONS]\n\n", program_name); - printf("Options:\n"); - printf(" -S, --sound SOUND_NAME Select keyboard sound pack (default: " - "eg-oreo)\n"); + printf("KeyVibe - Mechanical Keyboard Sound Simulator\n"); + printf("Version: %s\n\n", PROJECT_VERSION); + + printf("USAGE:\n"); + printf(" %s [OPTIONS]\n\n", program_name); + + printf("SOUND CONTROL:\n"); + printf(" -S, --sound PACK Keyboard sound pack (default: eg-oreo)\n"); + printf(" -M, --mouse PACK Mouse sound pack (default: ping)\n"); + printf(" -l, --list List available sound packs\n\n"); + + printf("VOLUME CONTROL:\n"); printf( - " -M, --mouse SOUND_NAME Select mouse sound pack (default: ping)\n"); - printf(" -V, --volume VOLUME Set volume [0-100] for both keyboard and " - "mouse (default: 50)\n"); - printf(" -K, --keyboard-volume VOLUME Set keyboard volume [0-100] " - "(default: 50)\n"); - printf(" -O, --mouse-volume VOLUME Set mouse volume [0-100] (default: " - "50)\n"); - printf(" -l, --list List available sound packs\n"); - printf(" -d, --daemon Run in background (write PID file)\n"); - printf(" -s, --stop Stop background daemon\n"); - printf(" -m, --mute[=DEVICE] Mute sounds (keyboard|mouse|both, " - "default: both)\n"); - printf(" -u, --unmute[=DEVICE] Unmute sounds (keyboard|mouse|both, " - "default: both)\n"); - printf(" -h, --help Show this help message\n"); + " -V, --volume LEVEL Set both keyboard & mouse volume [0-100]\n"); + printf(" -K, --keyboard-volume Set keyboard volume [0-100]\n"); + printf(" -O, --mouse-volume Set mouse volume [0-100]\n\n"); + + printf("MUTE CONTROL:\n"); + printf(" -m, --mute[=DEVICE] Mute sounds (keyboard|mouse|both)\n"); + printf(" -u, --unmute[=DEVICE] Unmute sounds (keyboard|mouse|both)\n\n"); + + printf("DAEMON CONTROL:\n"); + printf(" -d, --daemon Run in background\n"); + printf(" -s, --stop Stop background daemon\n\n"); + + printf("OTHER:\n"); printf(" -v, --verbose Enable verbose output\n"); - printf(" In daemon mode, editing ~/.keyvibe.json will auto-reload.\n"); + printf(" -h, --help Show this help\n\n"); + + printf("EXAMPLES:\n"); + printf(" %s --list # List sound packs\n", + program_name); + printf(" %s -S cherrymx-blue -V 75 # Cherry MX Blue at " + "75%%\n", + program_name); + printf(" %s --daemon # Run in background\n", + program_name); + printf(" %s --mute keyboard # Mute only keyboard\n", + program_name); + printf(" %s --keyboard-volume 80 --mouse-volume 60 # Different volumes\n", + program_name); + printf("\n"); + printf("CONFIG: Settings are saved to ~/.keyvibe.json and auto-reload in " + "daemon mode.\n"); } int parse_cli(int argc, char **argv, CliOptions *out) { @@ -66,7 +89,8 @@ int parse_cli(int argc, char **argv, CliOptions *out) { (n == 6 && strncmp(a, "unmute", 6) == 0) || (n == 4 && strncmp(a, "help", 4) == 0) || (n == 7 && strncmp(a, "verbose", 7) == 0))) { - fprintf(stderr, "Unknown option: %s (use full option name)\n", argv[i]); + fprintf(stderr, "Error: Unknown option '%s'\n", argv[i]); + fprintf(stderr, "Use '%s --help' for available options.\n", argv[0]); return 1; } } @@ -118,9 +142,8 @@ int parse_cli(int argc, char **argv, CliOptions *out) { } else if (strcmp(optarg, "mouse") == 0) { out->mouse_mute = 1; } else { - fprintf(stderr, - "Invalid mute option: %s. Use 'keyboard', 'mouse', or 'both'\n", - optarg); + fprintf(stderr, "Error: Invalid mute device '%s'\n", optarg); + fprintf(stderr, "Use: keyboard, mouse, or both\n"); return 1; } break; @@ -133,10 +156,8 @@ int parse_cli(int argc, char **argv, CliOptions *out) { } else if (strcmp(optarg, "mouse") == 0) { out->mouse_mute = 0; } else { - fprintf( - stderr, - "Invalid unmute option: %s. Use 'keyboard', 'mouse', or 'both'\n", - optarg); + fprintf(stderr, "Error: Invalid unmute device '%s'\n", optarg); + fprintf(stderr, "Use: keyboard, mouse, or both\n"); return 1; } break;