mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
rmdir: Add -v
option to list each directory as it is removed
This commit is contained in:
parent
307dc00ee0
commit
cba46a2d64
2 changed files with 6 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue