mirror of
https://github.com/fmang/opustags.git
synced 2025-01-15 20:53:16 +01:00
check for duplicate options
This commit is contained in:
parent
d67ce423d1
commit
7189d63c20
@ -67,11 +67,15 @@ ot::status ot::parse_options(int argc, char** argv, ot::options& opt)
|
||||
opt.print_help = true;
|
||||
break;
|
||||
case 'o':
|
||||
if (!opt.path_out.empty())
|
||||
return {st::bad_arguments, "Cannot specify --output more than once."};
|
||||
opt.path_out = optarg;
|
||||
if (opt.path_out.empty())
|
||||
return {st::bad_arguments, "Output file path cannot be empty."};
|
||||
break;
|
||||
case 'i':
|
||||
if (opt.inplace != nullptr)
|
||||
return {st::bad_arguments, "Cannot specify --in-place more than once."};
|
||||
opt.inplace = optarg == nullptr ? ".otmp" : optarg;
|
||||
if (strcmp(opt.inplace, "") == 0)
|
||||
return {st::bad_arguments, "In-place suffix cannot be empty."};
|
||||
|
3
t/cli.cc
3
t/cli.cc
@ -46,6 +46,9 @@ void check_bad_arguments()
|
||||
error_case({"opustags", "-S", "-"}, "Cannot use standard input as input file when --set-all is specified.",
|
||||
"set all and read opus from stdin");
|
||||
error_case({"opustags", "-i", "-"}, "Cannot modify standard input in-place.", "write stdin in-place");
|
||||
error_case({"opustags", "-o", "x", "--output", "y", "z"},
|
||||
"Cannot specify --output more than once.", "double output");
|
||||
error_case({"opustags", "-i", "-i", "z"}, "Cannot specify --in-place more than once.", "double in-place");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
x
Reference in New Issue
Block a user