Skip to content

feat: prompt to clear contexts when switching profiles - #236

Merged
aru-amedeo merged 3 commits into
mainfrom
feat/profile-use-clear-contexts
Jun 19, 2026
Merged

feat: prompt to clear contexts when switching profiles#236
aru-amedeo merged 3 commits into
mainfrom
feat/profile-use-clear-contexts

Conversation

@aru-amedeo

Copy link
Copy Markdown
Member

Summary

  • acloud config profile use <name> now asks whether to clear all contexts after switching profiles, since project IDs are tenant-scoped and unlikely to be valid across profiles
  • Interactive mode: prompts Contexts may not be valid for the new profile. Clear all contexts? (y/N):
  • Non-interactive mode (piped stdin / scripts): silently keeps contexts — no change to existing behaviour
  • New --clear-contexts flag: clears without prompting, useful in CI or automation

Changes

File Change
cmd/prompt.go Added promptConfirmOptional — yes/no prompt that returns false silently in non-interactive mode
cmd/context.go Added ClearAllContexts() — resets context file to empty state
cmd/config.go ConfigProfileUseRun wires the prompt + flag; --clear-contexts registered in init()
cmd/config_profile_test.go Two new tests: flag forces clear; non-interactive preserves contexts
docs/website/docs/configuration.md Callout documenting the behaviour and the flag

Test plan

  • acloud config profile use staging in a terminal — prompt appears, y/N works
  • acloud config profile use staging --clear-contexts — clears without prompt
  • Pipe to stdin (echo "" | acloud config profile use staging) — no prompt, contexts unchanged
  • Unit tests: go test ./cmd/ -run TestConfigProfileUse — 4 pass
  • Full suite: ACLOUD_TEST_SKIP_CLIENT=true go test ./cmd/ — no regressions

Generated with Claude Code

amedeopalopoli and others added 2 commits June 19, 2026 09:24
When a single context exists and no current context is set, GetCurrentProjectID
now returns that context project ID automatically, removing the need to run
acloud context use after acloud context set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When running `acloud config profile use`, the CLI now asks whether to
clear all saved contexts, since project IDs belong to a specific
tenant and may not be valid after a profile switch.

- Interactive mode: prompts "Clear all contexts? (y/N)"
- Non-interactive mode: keeps contexts by default
- --clear-contexts flag: clears without prompting (CI/scripts)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.09%. Comparing base (a3bc509) to head (0ce82f0).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/config.go 81.81% 1 Missing and 1 partial ⚠️
cmd/prompt.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #236   +/-   ##
=======================================
  Coverage   78.09%   78.09%           
=======================================
  Files          53       53           
  Lines       12438    12461   +23     
=======================================
+ Hits         9713     9732   +19     
- Misses       1565     1567    +2     
- Partials     1160     1162    +2     
Flag Coverage Δ
unittests 78.09% <83.33%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…e clear-contexts

Mirror the two English callouts added in feat/context-auto-select-single and
this branch into the Italian current docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aru-amedeo
aru-amedeo merged commit 80f5fbe into main Jun 19, 2026
12 checks passed
aru-amedeo pushed a commit that referenced this pull request Jun 19, 2026
Covers all changes since v0.5.1:
- feat: context auto-selection (#234)
- feat: clear-contexts prompt on profile switch (#236)
- fix: shell completion parent-ID slots for network sub-resources (#239/#240)
- fix: shell completion parent-ID slots for database/storage sub-resources (#241)
- fix: zone value in docs examples (#238)
- docs: English and Italian completion section updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aru-amedeo
aru-amedeo deleted the feat/profile-use-clear-contexts branch June 20, 2026 18:07
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.

2 participants