Skip to content

Commit

Permalink
add -O/--overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
nekopsykose committed Jun 23, 2024
1 parent e360252 commit 73d9ee1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions manpage/wf-recorder.1
Original file line number Diff line number Diff line change
Expand Up @@ -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 O, -overwrite
.Sh DESCRIPTION
.Nm
is a tool built to record your screen on Wayland compositors.
Expand Down Expand Up @@ -160,6 +161,9 @@ Set the output audio sample format.
.Pp
List available formats using
.Dl $ ffmpeg -sample_fmts
.Pp
.It Fl O , -overwrite
Force overwriting the output file without prompting.

.El
.Sh EXAMPLES
Expand Down
12 changes: 10 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ Use Ctrl+C to stop.)");
-P, --audio-codec-param Change the audio codec parameters.
-P <option_name>=<option_value>
-O, --overwrite Force overwriting the output file without prompting.
Examples:)");
#ifdef HAVE_PULSE
Expand Down Expand Up @@ -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' },
Expand All @@ -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, 'O' },
{ 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:O", opts, &i)) != -1)
{
switch(c)
{
Expand Down Expand Up @@ -1097,12 +1101,16 @@ int main(int argc, char *argv[])
force_no_dmabuf = true;
break;

case 'O':
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;
}
Expand Down

0 comments on commit 73d9ee1

Please sign in to comment.