1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +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:
Shannon Booth 2023-07-14 11:20:03 +12:00 committed by Andrew Kaster
parent 7bc3fd8c15
commit 4d8a59f34b

View file

@ -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)
{
StringView directory;
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);
if (!directory.is_null())
TRY(Core::System::chdir(directory));
auto input = TRY(Core::File::standard_input());
auto patch_content = TRY(input->read_until_eof());