Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ cli
cli
.command('space info')
.describe('Show information about a space. Defaults to the current space.')
.option('-s, --space', 'The space to print information about.')
.option(
'-s, --space <did>',
'The space DID to print information about (e.g. did:key:...)'
)
.option('--json', 'Format as newline delimited JSON')
.action(spaceInfo)

Expand Down
13 changes: 13 additions & 0 deletions packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ export async function useSpace(did) {
*/
export async function spaceInfo(opts) {
const client = await getClient()
if (typeof opts.space === 'boolean') {
Copy link
Member

@travis travis Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message here is wrong - --space does not require a value, it defaults to the currently selected space unless you specify a DID. I'd remove this whole clause - if space is given as a boolean it will be caught below in the other new check you added

console.error(
'Error: --space requires a DID value (e.g. --space did:key:...)'
)
process.exit(2)
}

const spaceDID = opts.space ?? client.currentSpace()?.did()
if (!spaceDID) {
console.error(
Expand All @@ -345,6 +352,12 @@ export async function spaceInfo(opts) {
process.exit(1)
}

// validate the value early for a clearer error
if (typeof spaceDID !== 'string' || !spaceDID.startsWith('did:')) {
console.error('Error: invalid DID. Expected something like "did:key:...".')
process.exit(2)
}

/** @type {import('@storacha/access/types').SpaceInfoResult} */
let info
try {
Expand Down