mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
rmdir: Add -v
option to list each directory as it is removed
This commit is contained in:
parent
307dc00ee0
commit
cba46a2d64
Notes:
sideshowbarker
2024-07-17 03:03:44 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/cba46a2d64 Pull-request: https://github.com/SerenityOS/serenity/pull/19489 Reviewed-by: https://github.com/LucasChollet ✅ Reviewed-by: https://github.com/gmta ✅
@ -15,6 +15,7 @@ Remove given `directory(ies)`, if they are empty
|
||||
## Options
|
||||
|
||||
* `-p`, `--parents`: Remove all directories in each given path
|
||||
* `-v`, `--verbose`: List each directory as it is removed
|
||||
|
||||
## Arguments
|
||||
|
||||
|
@ -16,16 +16,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
TRY(Core::System::pledge("stdio cpath"));
|
||||
|
||||
bool remove_parents = false;
|
||||
bool verbose = false;
|
||||
Vector<StringView> paths;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(remove_parents, "Remove all directories in each given path", "parents", 'p');
|
||||
args_parser.add_option(verbose, "List each directory as it is removed", "verbose", 'v');
|
||||
args_parser.add_positional_argument(paths, "Directories to remove", "paths");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
int status = 0;
|
||||
|
||||
auto remove_directory = [&](StringView path) {
|
||||
if (verbose)
|
||||
outln("rmdir: removing directory '{}'", path);
|
||||
|
||||
auto maybe_error = Core::System::rmdir(path);
|
||||
if (maybe_error.is_error()) {
|
||||
warnln("Failed to remove '{}': {}", path, maybe_error.release_error());
|
||||
|
Loading…
Reference in New Issue
Block a user