diff --git a/CliWrap/Builders/ArgumentsBuilder.cs b/CliWrap/Builders/ArgumentsBuilder.cs index 361c5dd7..3b474f41 100644 --- a/CliWrap/Builders/ArgumentsBuilder.cs +++ b/CliWrap/Builders/ArgumentsBuilder.cs @@ -142,7 +142,16 @@ public ArgumentsBuilder Add(IEnumerable values, bool escape) => public partial class ArgumentsBuilder { - private static string Escape(string argument) + /// + /// Escapes special characters (spaces, slashes, and quotes) in the specified string, ensuring that the output + /// is correctly interpreted as a single argument when passed to a command-line application. + /// + /// + /// In most cases, you should not need to use this method, as already escapes + /// arguments automatically. This method is provided for advanced scenarios where you need to escape arguments + /// manually. + /// + public static string Escape(string argument) { // Implementation reference: // https://github.com/dotnet/runtime/blob/9a50493f9f1125fda5e2212b9d6718bc7cdbc5c0/src/libraries/System.Private.CoreLib/src/System/PasteArguments.cs#L10-L79 diff --git a/Readme.md b/Readme.md index c47c7f1a..1f1f59a2 100644 --- a/Readme.md +++ b/Readme.md @@ -219,6 +219,10 @@ var cmd = Cli.Wrap("git") > This method expects all arguments to be correctly escaped and formatted ahead of time — which can be cumbersome to do yourself. > Formatting errors may result in unexpected bugs and security vulnerabilities. +> **Note**: +> There are some [obscure scenarios](https://github.com/Tyrrrz/CliWrap/issues/263), where you may need to assemble the command-line arguments yourself. +> In such cases, you can use the `ArgumentsBuilder.Escape(...)` method to escape individual arguments manually. + #### `WithWorkingDirectory(...)` Sets the working directory of the child process.