Skip to content

Commit cc72b2a

Browse files
fix: label-value spacing, profile switching discoverability
Fix labelValue padding when label is exactly LABEL_WIDTH chars. Show profile as "(active)" after root create --name. profile use now explains automatic usage and --profile override.
1 parent d85d037 commit cc72b2a

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/cli.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,12 @@ async function handleRoot(parsed, io, libraries, options, fmt) {
419419
fmt.warning('Store this mnemonic offline. It cannot be recovered.'),
420420
]
421421
if (savedProfile) {
422-
lines.splice(5, 0, fmt.labelValue('profile', savedProfile.name))
422+
lines.splice(5, 0, fmt.labelValue('profile', `${savedProfile.name} (active)`))
423423
lines.push(
424424
'',
425425
fmt.nextSteps([
426426
options.cmd('derive path personal'),
427-
options.cmd('export nsec personal'),
427+
options.cmd('derive path work/project-x'),
428428
]),
429429
)
430430
} else if (options.showHints) {
@@ -1045,6 +1045,9 @@ async function handleProfile(parsed, io, libraries, options, fmt) {
10451045
const lines = [
10461046
fmt.labelValue('active profile', name),
10471047
'',
1048+
` ${fmt.c.dim}All commands now use "${name}" automatically.${fmt.c.reset}`,
1049+
` ${fmt.c.dim}Or use --profile <name> for a one-off override.${fmt.c.reset}`,
1050+
'',
10481051
fmt.nextSteps([
10491052
options.cmd('derive path personal'),
10501053
options.cmd('root inspect'),

src/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function createFormatter({ colour = false } = {}) {
2525
: { reset: '', bold: '', dim: '', red: '', green: '', yellow: '', cyan: '' }
2626

2727
function labelValue(label, value) {
28-
const padded = label.padEnd(LABEL_WIDTH)
28+
const padded = label.length >= LABEL_WIDTH ? `${label} ` : label.padEnd(LABEL_WIDTH)
2929
return ` ${c.dim}${padded}${c.reset}${c.bold}${value}${c.reset}`
3030
}
3131

test/cli.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ describe('contextual next-steps (HATEOAS)', () => {
309309
)
310310
assert.equal(exitCode, 0)
311311
assert.match(io.stdoutBuffer, /derive path personal/, 'should suggest derive path')
312-
assert.match(io.stdoutBuffer, /export nsec personal/, 'should suggest export nsec')
312+
assert.match(io.stdoutBuffer, /derive path work\/project-x/, 'should show multiple example paths')
313+
assert.match(io.stdoutBuffer, /\(active\)/, 'should show profile as active')
313314
assert.doesNotMatch(io.stdoutBuffer, /profile save/, 'should not show profile save when --name was used')
314315
})
315316

0 commit comments

Comments
 (0)