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 de9fa4a
Showing 1 changed file with 10 additions and 2 deletions.
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 de9fa4a

Please sign in to comment.