Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

Resource.WithCommand

Method
📦 Aspire.Hosting v17.0.0
func (Resource) WithCommand(
name string,
displayName string,
executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult,
options ...*WithCommandOptions,
) Resource

Signature

methodWithCommandbuilder
Adds a resource command
WithCommand(
name string,
displayName string,
executeCommand func(arg ExecuteCommandContext) *ExecuteCommandResult,
options ...*WithCommandOptions,
) Resource
namestringThe name of the command. The name uniquely identifies the command.
displayNamestringThe display name visible in UI.
executeCommandfunc(arg ExecuteCommandContext) *ExecuteCommandResultcallbackA callback that is executed when the command is executed. The callback is run inside the Aspire host. The callback result is used to indicate success or failure in the UI.
options...*WithCommandOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithCommandOptions argument.

CommandOptions*CommandOptionsOptional configuration for the command.
Resource

The resource builder.

Returns a handle; failures surface later via Err().

Defined on

A marker interface declares no methods of its own in Go. Its functions are declared on the concrete types they apply to.

Applies to

This function applies to the following types: