Skip to content

Add TEAMS_CLI_PROFILE and stop shadowing the "default" profile - #58

Open
aberoham wants to merge 1 commit into
osodevops:mainfrom
aberoham:feat/profile-env-var
Open

Add TEAMS_CLI_PROFILE and stop shadowing the "default" profile#58
aberoham wants to merge 1 commit into
osodevops:mainfrom
aberoham:feat/profile-env-var

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

Fixes #53.
Fixes #55.

The global --profile flag becomes Option<String> with a TEAMS_CLI_PROFILE environment fallback, so scripts and agents can select a profile once per session instead of repeating the flag on every invocation. Precedence: --profile flag, then TEAMS_CLI_PROFILE, then the config's default.profile, then default — the same shape as the other auth environment variables.

Making the flag optional also distinguishes "not given" from an explicit --profile default. Previously the two were identical, so after teams auth switch <other> the switched profile shadowed the profile literally named "default" and it became unreachable from the command line; even --profile default auth login stored its token under the switched name. An explicit value now always wins, even when it is the literal default.

Unit tests cover the new resolve_profile precedence including the shadowing regression; integration tests cover environment selection, flag-beats-environment, and explicit-default-beats-config-default. The test harness now scrubs TEAMS_CLI_PROFILE alongside the other inherited auth variables. README and teams(1) document the variable.

cargo fmt, cargo clippy --all-targets -- -D warnings, and cargo test --all-targets pass (134 unit + 56 integration tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NXWLJ9g87M3GtLSACr2gmi

The global --profile flag becomes Option<String> with a
TEAMS_CLI_PROFILE env fallback, so scripts and agents can select a
profile once per session instead of repeating the flag on every
invocation. Precedence: flag, then env var, then the config's
default.profile, then "default".

Making the flag optional also distinguishes "not given" from an
explicit --profile default. Previously the two were identical, so after
`teams auth switch <other>` the switched profile shadowed the profile
literally named "default" and it became unreachable from the command
line; even `--profile default auth login` stored its token under the
switched name. An explicit value now always wins.

Fixes osodevops#53.
Fixes osodevops#55.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NXWLJ9g87M3GtLSACr2gmi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth switch makes the profile literally named "default" unreachable Support TEAMS_CLI_PROFILE environment variable for --profile

1 participant