From f16d278b05b7df7c453c168c2cf9b9ec9a485f0a Mon Sep 17 00:00:00 2001 From: Perry Date: Sun, 1 Oct 2023 17:34:57 -0300 Subject: [PATCH] Add missing doc comments and update README --- CommandExec/CommandUtils.cs | 10 +++++++++- README.md | 11 ++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CommandExec/CommandUtils.cs b/CommandExec/CommandUtils.cs index 69b88a6..e713387 100644 --- a/CommandExec/CommandUtils.cs +++ b/CommandExec/CommandUtils.cs @@ -17,7 +17,15 @@ public static Command Shell(params string[] args) Command shell = new Command(shellCommand).AddArg(shellArg); return shell.AddArg($"\"{string.Join(" ", args).Replace("\"", "\\\"")}"); } - + /// + /// Checks if a command exists. + /// + /// + /// This method will check for both shell commands and executable files. + /// There's a chance that the command exists, but needs to be executed through the shell. + /// + /// The command to check + /// Whether the command exists or not. public static bool Exists(string command) { Command cmd; diff --git a/README.md b/README.md index 550ed42..5e54da7 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,16 @@ for some reason.) ```cs using CommandExec; -// Initializing the Command class. Check the wiki (WIP) for more options. -Command dotnet = new Command("dotnet") { "--help" }; -dotnet.Run(); // Runs "dotnet --help". + +// Initializing the Command class. Check the wiki (TBD) for more options. +Command dotnet = new Command("dotnet") { "build", "--help" }; +dotnet.Run(); // Runs "dotnet build --help" synchronously. Task dotnetTask = dotnet.RunAsync(); // Runs asynchronously. Console.WriteLine("Dotnet help running..."); await dotnetTask; -Command shell = Command.Shell("dotnet", "--help"); // Creates the shell command. PowerShell on Windows, BASH on Linux/macOS. +Command shell = CommandUtils.Shell("echo", "Hello world!"); // Creates the shell command. PowerShell on Windows, /bin/sh on UNIX-like systems. shell.Run(); // Passing args with `Run` for shell commands is not recommended. ``` -Check more information about the `Command` class in the [Wiki (WIP)](https://github.com/perrylets/CommandExec/wiki) or the doc comments. +Check more information about the `Command` class in the [Wiki (TBD)](https://github.com/perrylets/CommandExec/wiki) or the doc comments.