(deps: UsageDeps = {})
| 188 | } |
| 189 | |
| 190 | export function createUsageCommand(deps: UsageDeps = {}): Command { |
| 191 | const cmd = new Command('usage') |
| 192 | .alias('credits') |
| 193 | .description( |
| 194 | 'Show credit balance and plan/entitlement info (proactive pre-flight before a large test run)', |
| 195 | ) |
| 196 | .addHelpText('after', GLOBAL_OPTS_HINT) |
| 197 | .addHelpText( |
| 198 | 'after', |
| 199 | '\nExamples:\n' + |
| 200 | ' testsprite usage # show balance + plan\n' + |
| 201 | ' testsprite usage --output json # machine-readable balance\n' + |
| 202 | ' testsprite credits # alias for usage\n' + |
| 203 | '\nNote: credit balance requires a backend update to /me. Until shipped,\n' + |
| 204 | " check your portal's Billing page (/dashboard/settings/billing) for your balance.", |
| 205 | ) |
| 206 | .action(async (_cmdOpts, command: Command) => { |
| 207 | await runUsage(resolveCommonOptions(command), deps); |
| 208 | }); |
| 209 | |
| 210 | return cmd; |
| 211 | } |
| 212 | |
| 213 | function resolveCommonOptions(command: Command): CommonOptions { |
| 214 | const globals = command.optsWithGlobals() as Partial<CommonOptions> & { |
no test coverage detected