diff --git a/src/legacy/legacy-cli.ts b/src/legacy/legacy-cli.ts index 16fc81c..e097412 100644 --- a/src/legacy/legacy-cli.ts +++ b/src/legacy/legacy-cli.ts @@ -1982,19 +1982,29 @@ async function main(): Promise { } if (switchToProfile(profileName)) { - console.log(`✓ Switched to wallet profile: ${profileName}`); + // Issue sphere-sdk#282 Residual #2 — confirmation output + // goes to STDERR so that pipelines capturing the NEXT + // command's stdout (e.g. `sphere wallet use alice && + // sphere balance > file`) don't accidentally include the + // wallet-use banner in the captured snapshot. Without + // this, the same logical command sequence produces + // different captured-stdout content depending on whether + // the harness redirects the `wallet use` invocation + // separately or groups it in a subshell — see the + // peer1-vs-peer2 asymmetry in `manual-test-full-recovery.sh`. + console.error(`✓ Switched to wallet profile: ${profileName}`); // Show wallet status try { const sphere = await getSphere(); const identity = sphere.identity; if (identity) { - console.log(` Nametag: ${identity.nametag || '(not set)'}`); - console.log(` L1 Addr: ${identity.l1Address}`); + console.error(` Nametag: ${identity.nametag || '(not set)'}`); + console.error(` L1 Addr: ${identity.l1Address}`); } await closeSphere(); } catch { - console.log(' (wallet not initialized in this profile)'); + console.error(' (wallet not initialized in this profile)'); } } else { console.error(`Profile "${profileName}" not found.`); diff --git a/test/integration/cli-wallet-profile.integration.test.ts b/test/integration/cli-wallet-profile.integration.test.ts index eb44975..45c3dbe 100644 --- a/test/integration/cli-wallet-profile.integration.test.ts +++ b/test/integration/cli-wallet-profile.integration.test.ts @@ -230,7 +230,11 @@ describe('sphere-cli — wallet profile CRUD lifecycle (offline)', () => { it('`wallet use alice` switches the active profile', () => { const r = runSphere(env, ['wallet', 'use', 'alice'], { timeoutMs: 15_000 }); expect(r.status).toBe(0); - expect(r.stdout).toMatch(/Switched to wallet profile:\s*alice/); + // sphere-sdk#282 Residual #2 — confirmation lives on STDERR so + // downstream `sphere wallet use … && sphere balance > file` shell + // pipelines don't fold the banner into the captured snapshot. + expect(r.stderr).toMatch(/Switched to wallet profile:\s*alice/); + expect(r.stdout).not.toMatch(/Switched to wallet profile/); // Verify by re-reading current. const current = runSphere(env, ['wallet', 'current'], { timeoutMs: 15_000 });