From 03ef7d0964944c058c34b6b1e2bb8bbf5f5a8e24 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 18 Apr 2023 18:41:06 +0200 Subject: Show shorter form of help on argument error --- src/main.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index a7db997..05db5b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -632,8 +632,12 @@ static void open_video(AVCodecContext *codec_context, VideoQuality video_quality } } -static void usage() { - fprintf(stderr, "usage: gpu-screen-recorder -w [-c ] [-s WxH] -f [-a ] [-q ] [-r ] [-k h264|h265] [-ac aac|opus|flac] [-oc yes|no] [-v yes|no] [-o ]\n"); +static void usage_header() { + fprintf(stderr, "usage: gpu-screen-recorder -w [-c ] [-s WxH] -f [-a ] [-q ] [-r ] [-k h264|h265] [-ac aac|opus|flac] [-oc yes|no] [-v yes|no] [-h|--help] [-o ]\n"); +} + +static void usage_full() { + usage_header(); fprintf(stderr, "\n"); fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, " -w Window to record, a display, \"screen\", \"screen-direct\", \"screen-direct-force\" or \"focused\".\n"); @@ -671,10 +675,12 @@ static void usage() { fprintf(stderr, "\n"); fprintf(stderr, " -oc Overclock memory transfer rate to the maximum performance level. This only applies to NVIDIA and exists to overcome a bug in NVIDIA driver where performance level\n"); fprintf(stderr, " is dropped when you record a game. Only needed if you are recording a game that is bottlenecked by GPU.\n"); - fprintf(stderr, " Works only if your have \"Coolbits\" set to \"12\" in NVIDIA X settings, see README for more information. Note! use at your own risk! Optional, disabled by default\n"); + fprintf(stderr, " Works only if your have \"Coolbits\" set to \"12\" in NVIDIA X settings, see README for more information. Note! use at your own risk! Optional, disabled by default.\n"); fprintf(stderr, "\n"); fprintf(stderr, " -v Prints per second, fps updates. Optional, set to 'yes' by default.\n"); fprintf(stderr, "\n"); + fprintf(stderr, " -h Show this help.\n"); + fprintf(stderr, "\n"); //fprintf(stderr, " -pixfmt The pixel format to use for the output video. yuv420 is the most common format and is best supported, but the color is compressed, so colors can look washed out and certain colors of text can look bad. Use yuv444 for no color compression, but the video may not work everywhere and it may not work with hardware video decoding. Optional, defaults to yuv420\n"); fprintf(stderr, " -o The output file path. If omitted then the encoded data is sent to stdout. Required in replay mode (when using -r).\n"); fprintf(stderr, " In replay mode this has to be an existing directory instead of a file.\n"); @@ -690,6 +696,11 @@ static void usage() { exit(1); } +static void usage() { + usage_header(); + exit(1); +} + static sig_atomic_t running = 1; static sig_atomic_t save_replay = 0; @@ -1064,8 +1075,11 @@ int main(int argc, char **argv) { signal(SIGINT, int_handler); signal(SIGUSR1, save_replay_handler); - if(argc == 0) - usage(); + if(argc <= 1) + usage_full(); + + if(argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) + usage_full(); //av_log_set_level(AV_LOG_TRACE); -- cgit v1.2.3