mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-02 06:09:51 +00:00
patch: Implement d, --directory option
When given, patch will chdir into the given directory before processing the patch file.
This commit is contained in:
parent
7bc3fd8c15
commit
4d8a59f34b
Notes:
sideshowbarker
2024-07-17 06:20:50 +09:00
Author: https://github.com/shannonbooth
Commit: 4d8a59f34b
Pull-request: https://github.com/SerenityOS/serenity/pull/20007
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
1 changed files with 6 additions and 0 deletions
|
@ -29,9 +29,15 @@ static ErrorOr<void> do_patch(StringView path_of_file_to_patch, Diff::Patch cons
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
|
StringView directory;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
|
args_parser.add_option(directory, "Change the working directory to <directory> before applying the patch file", "directory", 'd', "directory");
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
if (!directory.is_null())
|
||||||
|
TRY(Core::System::chdir(directory));
|
||||||
|
|
||||||
auto input = TRY(Core::File::standard_input());
|
auto input = TRY(Core::File::standard_input());
|
||||||
|
|
||||||
auto patch_content = TRY(input->read_until_eof());
|
auto patch_content = TRY(input->read_until_eof());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue