Skip to main content
Version: 3.x

Custom Commands

Many common CLI tools, such as npm, yarn, dotnet, docker, kubectl, have all had strong objects created to wrap around their CLI commands.

If you want to run a command that isn't currently supported by strong objects, you can still run commands directly through the ICommandContext interface available via context.Shell.Command within your modules.

Every argument should be passed as a separate string in a collection. This allows proper formatting if there's things like spaces or quotes.

Example

await context.Shell.Command.ExecuteCommandLineTool(new CommandLineToolOptions("dotnet")
{
Arguments = new[] { "tool", "install", "--global", "dotnet-coverage" },
}, cancellationToken);

This is the equivalent to running:

dotnet tool install --global dotnet-coverage