mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
Userland: Add -v verbose flag to 'rm'
This commit is contained in:
parent
2dab9d4bac
commit
f23d9a73aa
Notes:
sideshowbarker
2024-07-19 01:21:52 +09:00
Author: https://github.com/SpencerCDixon
Commit: f23d9a73aa
Pull-request: https://github.com/SerenityOS/serenity/pull/4107
1 changed files with 4 additions and 0 deletions
|
@ -82,17 +82,21 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
bool recursive = false;
|
bool recursive = false;
|
||||||
bool force = false;
|
bool force = false;
|
||||||
|
bool verbose = false;
|
||||||
Vector<const char*> paths;
|
Vector<const char*> paths;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_option(recursive, "Delete directories recursively", "recursive", 'r');
|
args_parser.add_option(recursive, "Delete directories recursively", "recursive", 'r');
|
||||||
args_parser.add_option(force, "Force", "force", 'f');
|
args_parser.add_option(force, "Force", "force", 'f');
|
||||||
|
args_parser.add_option(verbose, "Verbose", "verbose", 'v');
|
||||||
args_parser.add_positional_argument(paths, "Path(s) to remove", "path");
|
args_parser.add_positional_argument(paths, "Path(s) to remove", "path");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
for (auto& path : paths) {
|
for (auto& path : paths) {
|
||||||
rc |= remove(recursive, force, path);
|
rc |= remove(recursive, force, path);
|
||||||
|
if (verbose && rc == 0)
|
||||||
|
printf("removed '%s'\n", path);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue