mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 20:04:26 +00:00
feat(cli): generate shumai-cli commands from Operations with commander (#496)
Rebuild the CLI on commander. Commands for every cli-surface Operation (project ls, ls, mkdir, rename, move/mv, delete/rm) are generated from @shumai/operations: positionals, options, choices, numeric parsing and help text come from the Zod input schema. They call POST /api/ops/:name with x-shumai-client: cli. Existing invocations keep working. Adds --json, ls --type/--first/ --after, typo suggestions, and generated help. upload and create-version stay hand-written. Drops the unused @shumai/core dependency.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/** An expected failure, printed as `Error: <message>` with exit code 1. */
|
||||
export class CliError extends Error {
|
||||
/** When true, the message already carries its own prefix and is printed as-is. */
|
||||
readonly prefixed: boolean
|
||||
|
||||
constructor(message: string, options: { prefixed?: boolean } = {}) {
|
||||
super(message)
|
||||
this.name = 'CliError'
|
||||
this.prefixed = options.prefixed ?? false
|
||||
}
|
||||
}
|
||||
|
||||
export function formatCliError(err: unknown): string {
|
||||
if (err instanceof CliError) {
|
||||
return err.prefixed ? err.message : `Error: ${err.message}`
|
||||
}
|
||||
return `Unexpected error: ${err instanceof Error ? err.message : String(err)}`
|
||||
}
|
||||
Reference in New Issue
Block a user