Skip to content

Commit

Permalink
Updates how args are sent to extension command
Browse files Browse the repository at this point in the history
  • Loading branch information
wbreza committed Nov 18, 2024
1 parent b252a17 commit 3a6ba44
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cli/azd/cmd/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,30 @@ type extensionAction struct {
commandRunner exec.CommandRunner
lazyEnv *lazy.Lazy[*environment.Environment]
extensionManager *extensions.Manager
cmd *cobra.Command
args []string
}

func newExtensionAction(
console input.Console,
commandRunner exec.CommandRunner,
lazyEnv *lazy.Lazy[*environment.Environment],
extensionManager *extensions.Manager,
cmd *cobra.Command,
args []string,
) actions.Action {
return &extensionAction{
console: console,
commandRunner: commandRunner,
lazyEnv: lazyEnv,
extensionManager: extensionManager,
cmd: cmd,
args: args,
}
}

func (a *extensionAction) Run(ctx context.Context) (*actions.ActionResult, error) {
extensionName := os.Args[1]
extensionName := a.cmd.Use

extension, err := a.extensionManager.GetInstalled(extensionName)
if err != nil {
Expand All @@ -134,9 +140,6 @@ func (a *extensionAction) Run(ctx context.Context) (*actions.ActionResult, error
allEnv = append(allEnv, env.Environ()...)
}

allArgs := []string{}
allArgs = append(allArgs, os.Args[2:]...)

cwd, err := os.Getwd()
if err != nil {
return nil, fmt.Errorf("failed to get current working directory: %w", err)
Expand All @@ -155,7 +158,7 @@ func (a *extensionAction) Run(ctx context.Context) (*actions.ActionResult, error
}

runArgs := exec.
NewRunArgs(extensionPath, allArgs...).
NewRunArgs(extensionPath, a.args...).
WithCwd(cwd).
WithEnv(allEnv).
WithStdIn(a.console.Handles().Stdin).
Expand Down

0 comments on commit 3a6ba44

Please sign in to comment.