Skip to content

Commit 6e91972

Browse files
authored
azd x support interactive (#6367)
* Adding extension and grpc layer for services * ignore binary * wip * wip * cspell * updates to mod * Support interactive invocation opt-in for extensions * cleaner way to show interactive override from extensions owning the terminal * revert and make interactive by default * set interactive option for the call
1 parent 6d7e3e5 commit 6e91972

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

cli/azd/cmd/extensions.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ func (a *extensionAction) Run(ctx context.Context) (*actions.ActionResult, error
182182
}
183183

184184
options := &extensions.InvokeOptions{
185-
Args: a.args,
186-
Env: allEnv,
187-
StdIn: a.console.Handles().Stdin,
188-
StdOut: a.console.Handles().Stdout,
189-
StdErr: a.console.Handles().Stderr,
185+
Args: a.args,
186+
Env: allEnv,
187+
// cmd extensions are always interactive (connected to terminal)
188+
Interactive: true,
190189
}
191190

192191
_, err = a.extensionRunner.Invoke(ctx, extension, options)

cli/azd/pkg/extensions/runner.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import (
1515
)
1616

1717
type InvokeOptions struct {
18-
Args []string
19-
Env []string
20-
StdIn io.Reader
21-
StdOut io.Writer
22-
StdErr io.Writer
18+
Args []string
19+
Env []string
20+
StdIn io.Reader
21+
StdOut io.Writer
22+
StdErr io.Writer
23+
Interactive bool
2324
}
2425

2526
type Runner struct {
@@ -51,16 +52,20 @@ func (r *Runner) Invoke(ctx context.Context, extension *Extension, options *Invo
5152
runArgs = runArgs.WithEnv(options.Env)
5253
}
5354

54-
if options.StdIn != nil {
55-
runArgs = runArgs.WithStdIn(options.StdIn)
56-
}
55+
if options.Interactive {
56+
runArgs = runArgs.WithInteractive(true)
57+
} else {
58+
if options.StdIn != nil {
59+
runArgs = runArgs.WithStdIn(options.StdIn)
60+
}
5761

58-
if options.StdOut != nil {
59-
runArgs = runArgs.WithStdOut(options.StdOut)
60-
}
62+
if options.StdOut != nil {
63+
runArgs = runArgs.WithStdOut(options.StdOut)
64+
}
6165

62-
if options.StdErr != nil {
63-
runArgs = runArgs.WithStdErr(options.StdErr)
66+
if options.StdErr != nil {
67+
runArgs = runArgs.WithStdErr(options.StdErr)
68+
}
6469
}
6570

6671
runResult, err := r.commandRunner.Run(ctx, runArgs)

0 commit comments

Comments
 (0)