From 761e24d88bac847e406c4427ec6d487715c5d04c Mon Sep 17 00:00:00 2001 From: psykose Date: Mon, 24 Jun 2024 00:10:55 +0200 Subject: [PATCH] add -y/--overwrite --- manpage/wf-recorder.1 | 4 ++++ src/main.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/manpage/wf-recorder.1 b/manpage/wf-recorder.1 index 88a6127..1e0506c 100644 --- a/manpage/wf-recorder.1 +++ b/manpage/wf-recorder.1 @@ -29,6 +29,7 @@ .Op Fl P, -audio-codec-param Op Ar option_param=option_value .Op Fl R, -sample-rate Ar sample_rate .Op Fl X, -sample-format Ar sample_format +.Op Fl y, -overwrite .Sh DESCRIPTION .Nm is a tool built to record your screen on Wayland compositors. @@ -160,6 +161,9 @@ Set the output audio sample format. .Pp List available formats using .Dl $ ffmpeg -sample_fmts +.Pp +.It Fl y , -overwrite +Force overwriting the output file without prompting. .El .Sh EXAMPLES diff --git a/src/main.cpp b/src/main.cpp index 62d5106..0a14985 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -878,6 +878,8 @@ Use Ctrl+C to stop.)"); -P, --audio-codec-param Change the audio codec parameters. -P = + + -y, --overwrite Force overwriting the output file without prompting. Examples:)"); #ifdef HAVE_PULSE @@ -971,6 +973,7 @@ int main(int argc, char *argv[]) constexpr const char* default_cmdline_output = "interactive"; std::string cmdline_output = default_cmdline_output; bool force_no_dmabuf = false; + bool force_overwrite = false; struct option opts[] = { { "output", required_argument, NULL, 'o' }, @@ -995,11 +998,12 @@ int main(int argc, char *argv[]) { "buffrate", required_argument, NULL, 'B' }, { "version", no_argument, NULL, 'v' }, { "no-damage", no_argument, NULL, 'D' }, + { "overwrite", no_argument, NULL, 'y' }, { 0, 0, NULL, 0 } }; int c, i; - while((c = getopt_long(argc, argv, "o:f:m:g:c:p:r:x:C:P:R:X:d:b:B:la::hvDF:", opts, &i)) != -1) + while((c = getopt_long(argc, argv, "o:f:m:g:c:p:r:x:C:P:R:X:d:b:B:la::hvDF:y", opts, &i)) != -1) { switch(c) { @@ -1097,12 +1101,16 @@ int main(int argc, char *argv[]) force_no_dmabuf = true; break; + case 'y': + force_overwrite = true; + break; + default: printf("Unsupported command line argument %s\n", optarg); } } - if (!user_specified_overwrite(params.file)) + if (!force_overwrite && !user_specified_overwrite(params.file)) { return EXIT_FAILURE; }