Add --non-interactive alias and AZD_NON_INTERACTIVE env var#7392
Add --non-interactive alias and AZD_NON_INTERACTIVE env var#7392
Conversation
…7388) - Add --non-interactive as a hidden global flag alias for --no-prompt - Add AZD_NON_INTERACTIVE environment variable support (strconv.ParseBool) - Priority: explicit flag > env var > agent auto-detection - Setting AZD_NON_INTERACTIVE (even to false) suppresses agent auto-detection - Add table-driven tests for all flag/env/priority combinations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds an additional way to enable azd’s non-interactive mode by introducing a hidden --non-interactive global flag (as an alias for --no-prompt) and adding AZD_NON_INTERACTIVE environment variable support, with explicit flags taking precedence over env var and agent auto-detection.
Changes:
- Add hidden global flag
--non-interactiveas an alias for--no-prompt. - Add
AZD_NON_INTERACTIVEenv var parsing (truthy viastrconv.ParseBool) and suppress agent auto-detection when the env var is present. - Add table-driven tests covering flag/env-var combinations and precedence.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cli/azd/internal/global_command_options.go | Updates NoPrompt documentation to describe new flag/env-var enablement paths. |
| cli/azd/cmd/auto_install.go | Adds --non-interactive flag, parses AZD_NON_INTERACTIVE, and adjusts precedence vs agent detection. |
| cli/azd/cmd/auto_install_test.go | Adds table-driven tests for alias/env-var behavior and precedence. |
- Use OR logic for --no-prompt/--non-interactive (either opt-in wins) - Unset AZD_NON_INTERACTIVE in test setup to prevent ambient pollution Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Add --non-interactive alias and AZD_NON_INTERACTIVE env var by @spboyer
Summary
What: Adds a hidden --non-interactive global flag alias for --no-prompt and introduces the AZD_NON_INTERACTIVE environment variable for controlling non-interactive mode. Priority order: explicit flags > env var > agent auto-detection.
Why: Provides a more standard --non-interactive / AZD_NON_INTERACTIVE interface that CI/CD tools and automation scripts expect (fixes #7387, #7388).
Assessment: The implementation is clean and the priority layering is solid. The 13 table-driven tests cover the key flag/env combinations well. Two gaps worth addressing: the shared test helper clearAgentEnvVarsForTest needs to include the new env var, and unparseable env var values are silently ignored while also suppressing agent detection. Also note: the ParseGlobalFlags function doc comment (line ~633) still only mentions --no-prompt - it should be updated to mention --non-interactive and AZD_NON_INTERACTIVE.
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic | 0 | 1 | 0 | 0 |
| Error Handling | 0 | 0 | 1 | 0 |
| Total | 0 | 1 | 1 | 0 |
What's done well
- Clean priority layering: flag > env var > agent detection
- Hidden flag avoids polluting help output
- Solid table-driven test structure matching existing patterns
- Good struct doc comments explaining all enablement paths
2 inline comments below.
- Add AZD_NON_INTERACTIVE to clearAgentEnvVarsForTest so all tests using ParseGlobalFlags are isolated from the ambient environment. - Remove redundant manual t.Setenv/os.Unsetenv now handled by the helper. - Log a warning when AZD_NON_INTERACTIVE has an unparseable value (e.g. 'yes', 'on', empty) so users understand why their setting was ignored. - Add test case for AZD_NON_INTERACTIVE=yes documenting the expected behavior (warning logged, agent detection suppressed, NoPrompt false). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Previous issues fixed. One minor nit inline. Also: ParseGlobalFlags doc comment (line 643) still says "If --no-prompt is not explicitly set" - now stale since the function also checks --non-interactive and AZD_NON_INTERACTIVE.
Not blocking.
Set CLAUDE_CODE=1 so agent detection would fire, then verify AZD_NON_INTERACTIVE=false prevents NoPrompt from being set. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use switch statement for TestPtr to keep nil-check and dereference in the same branch. Add nolint directive for TestMCPSecurityFluentBuilder where t.Fatal guarantees non-nil. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace manual nil-check + t.Fatal with require.NotNil which makes staticcheck aware the pointer is non-nil for subsequent accesses. Convert all manual assertions to require.True/require.Len. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
Reviewed 6 files (+206 -32). Checked flag integration (Cobra, extractGlobalArgs), env var parsing, priority logic, edge cases, and test coverage - clean. All previous feedback addressed.
- Add AZD_NON_INTERACTIVE environment variable to environment-variables.md (--non-interactive flag alias and env var, PR Azure#7392) - Add azd auth token usage section to external-authentication.md (raw token output by default, --output json for structured output, PR Azure#7384) - Add Docker build network option to proxy-configuration.md (docker.network field in azure.yaml for builds behind corporate proxies, PR Azure#7361) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 1.24.0 (Unreleased) CHANGELOG section documenting: - --non-interactive flag alias and AZD_NON_INTERACTIVE env var (Azure#7392) - Hooks per provisioning layer in azure.yaml (Azure#7382) - Docker build network option in azure.yaml (Azure#7361) - Improved azd update error message for admin-managed installs (Azure#7417) - Deprecation of -e short flag in AI extensions (Azure#7313) - Add AZD_NON_INTERACTIVE to environment-variables.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Add
--non-interactiveas a global flag alias for--no-promptand support theAZD_NON_INTERACTIVEenvironment variable for enabling non-interactive mode.Changes
--non-interactiveflag: Hidden global flag alias for--no-prompt(backward-compatible)AZD_NON_INTERACTIVEenv var: When set to a truthy value (true,1,TRUE, etc. viastrconv.ParseBool), enables no-prompt mode--no-prompt/--non-interactiveflag (highest) >AZD_NON_INTERACTIVEenv var > agent auto-detection (lowest)AZD_NON_INTERACTIVE(even tofalse) suppresses agent auto-detection, giving users explicit controlFiles Modified
cli/azd/cmd/auto_install.go— Flag definition + env var parsing inCreateGlobalFlagSet()/ParseGlobalFlags()cli/azd/internal/global_command_options.go— UpdatedNoPromptdoc commentcli/azd/cmd/auto_install_test.go— Table-driven tests for flag alias, env var, and priorityTesting
cmdtests passFixes #7387
Fixes #7388