Skip to content

Commit

Permalink
Merge pull request #7 from perrylets/doc-comments
Browse files Browse the repository at this point in the history
Add missing doc comments and update README
  • Loading branch information
perrylets authored Oct 1, 2023
2 parents bf904ec + f16d278 commit 7459b0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CommandExec/CommandUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("\"", "\\\"")}");
}

/// <summary>
/// Checks if a command exists.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name="command">The command to check</param>
/// <returns>Whether the command exists or not.</returns>
public static bool Exists(string command)
{
Command cmd;
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 7459b0b

Please sign in to comment.