mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
Userland: Add -v verbose flag to 'mv'
This commit is contained in:
parent
7ba28b5b0b
commit
2dab9d4bac
1 changed files with 6 additions and 0 deletions
|
@ -41,12 +41,14 @@ int main(int argc, char** argv)
|
||||||
// NOTE: The "force" option is a dummy for now, it's just here to silence scripts that use "mv -f"
|
// NOTE: The "force" option is a dummy for now, it's just here to silence scripts that use "mv -f"
|
||||||
// In the future, it might be used to cancel out an "-i" interactive option.
|
// In the future, it might be used to cancel out an "-i" interactive option.
|
||||||
bool force = false;
|
bool force = false;
|
||||||
|
bool verbose = false;
|
||||||
|
|
||||||
const char* old_path = nullptr;
|
const char* old_path = nullptr;
|
||||||
const char* new_path = nullptr;
|
const char* new_path = nullptr;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
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(old_path, "The file or directory being moved", "source");
|
args_parser.add_positional_argument(old_path, "The file or directory being moved", "source");
|
||||||
args_parser.add_positional_argument(new_path, "destination of the move operation", "destination");
|
args_parser.add_positional_argument(new_path, "destination of the move operation", "destination");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
@ -71,5 +73,9 @@ int main(int argc, char** argv)
|
||||||
perror("rename");
|
perror("rename");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
printf("renamed '%s' -> '%s'\n", old_path, new_path);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue