mirror of
https://github.com/fmang/opustags.git
synced 2024-11-13 00:42:46 +01:00
Options: change in_place to contain bool
This should minify conditional statements to just one, after finishing work, whether to move the path_out back to the original file.
This commit is contained in:
parent
be3984423f
commit
7f7766f175
@ -60,7 +60,8 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
options.in_place = arg.empty() ? ".otmp" : arg;
|
||||
options.path_out = arg.empty() ? ".otmp" : arg;
|
||||
options.in_place = true;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
|
@ -15,7 +15,7 @@ namespace opustags
|
||||
bool overwrite;
|
||||
bool set_all;
|
||||
|
||||
std::string in_place;
|
||||
bool in_place;
|
||||
std::string path_out;
|
||||
|
||||
CompositeTagsHandler tags_handler;
|
||||
|
@ -62,13 +62,20 @@ TEST_CASE("option parsing", "[options]")
|
||||
}
|
||||
|
||||
SECTION("--in-place") {
|
||||
REQUIRE(retrieve_options({"-i"}).in_place == ".otmp");
|
||||
REQUIRE(retrieve_options({"--in-place"}).in_place == ".otmp");
|
||||
REQUIRE(retrieve_options({"--in-place=ABC"}).in_place == "ABC");
|
||||
REQUIRE(retrieve_options({"-iABC"}).in_place == "ABC");
|
||||
REQUIRE(retrieve_options({"--in-place", "ABC"}).in_place == ".otmp");
|
||||
REQUIRE(retrieve_options({"-i", "ABC"}).in_place == ".otmp");
|
||||
REQUIRE(retrieve_options({}).in_place.empty());
|
||||
REQUIRE(!retrieve_options({}).in_place);
|
||||
REQUIRE(retrieve_options({}).path_out.empty());
|
||||
REQUIRE(retrieve_options({"--in-place", "ABC"}).in_place);
|
||||
REQUIRE(retrieve_options({"--in-place", "ABC"}).path_out == ".otmp");
|
||||
REQUIRE(retrieve_options({"--in-place"}).in_place);
|
||||
REQUIRE(retrieve_options({"--in-place"}).path_out == ".otmp");
|
||||
REQUIRE(retrieve_options({"--in-place=ABC"}).in_place);
|
||||
REQUIRE(retrieve_options({"--in-place=ABC"}).path_out == "ABC");
|
||||
REQUIRE(retrieve_options({"-i", "ABC"}).in_place);
|
||||
REQUIRE(retrieve_options({"-i", "ABC"}).path_out == ".otmp");
|
||||
REQUIRE(retrieve_options({"-i"}).in_place);
|
||||
REQUIRE(retrieve_options({"-i"}).path_out == ".otmp");
|
||||
REQUIRE(retrieve_options({"-iABC"}).in_place);
|
||||
REQUIRE(retrieve_options({"-iABC"}).path_out == "ABC");
|
||||
}
|
||||
|
||||
SECTION("--output") {
|
||||
|
Loading…
Reference in New Issue
Block a user