also looking at this
feat: add retained cargo fleet cancellation and recovery
#105
32 files
+2496
-27
| @@ -0,0 +1,27 @@ | ||
| 1 | import { defineCommand } from '@stacksjs/cli' | |
| 2 | import { printAsync, printErrorAsync } from '../../resources/functions/cli/output' | |
| 3 | import { cargoFleetSummary } from '../../resources/functions/drone/cargo/fleet' | |
| 4 | import { cargoFleetOperatorCases, simulateCargoFleetControl } from '../../resources/functions/drone/cargo/fleet-control' | |
| 5 | ||
| 6 | export default defineCommand({ | |
| 7 | name: 'cargo:fleet-control', | |
| 8 | description: 'Exercise explicit modeled transport cancellation and recovery over the retained two-carrier world', | |
| 9 | options: { | |
| 10 | '--case <name>': { description: cargoFleetOperatorCases.join(', '), default: 'cancel-resume' }, | |
| 11 | }, | |
| 12 | async handle(options) { | |
| 13 | try { | |
| 14 | const fixture = simulateCargoFleetControl({ case: options.case }) | |
| 15 | const summary = { ...cargoFleetSummary(fixture.run), operatorCase: fixture.case } | |
| 16 | if (summary.status !== 'completed') process.exitCode = 2 | |
| 17 | const wire = JSON.stringify(summary) | |
| 18 | if (Buffer.byteLength(wire) + 1 > 16384) throw new RangeError('cargo-fleet-control-output-limit') | |
| 19 | await printAsync(wire) | |
| 20 | } | |
| 21 | catch { | |
| 22 | process.exitCode = 1 | |
| 23 | try { await printErrorAsync('Cargo fleet control unavailable: invalid case, execution or output failure') } | |
| 24 | catch { /* A closed diagnostic pipe does not make the failed command succeed. */ } | |
| 25 | } | |
| 26 | }, | |
| 27 | }) | |