also looking at this
feat: coordinate modeled two-carrier cargo handover
#103
25 files
+1654
-13
| @@ -0,0 +1,25 @@ | ||
| 1 | import { defineCommand } from '@stacksjs/cli' | |
| 2 | import { printAsync, printErrorAsync } from '../../resources/functions/cli/output' | |
| 3 | import { cargoFleetScenarios, cargoFleetSummary, simulateCargoFleet } from '../../resources/functions/drone/cargo/fleet' | |
| 4 | ||
| 5 | export default defineCommand({ | |
| 6 | name: 'cargo:fleet', | |
| 7 | description: 'Run two owned modeled carriers through one finite station and captured intake, without physical dispatch', | |
| 8 | options: { | |
| 9 | '--scenario <name>': { description: cargoFleetScenarios.join(', '), default: 'nominal' }, | |
| 10 | }, | |
| 11 | async handle(options) { | |
| 12 | try { | |
| 13 | const summary = cargoFleetSummary(simulateCargoFleet({ scenario: options.scenario })) | |
| 14 | if (summary.status !== 'completed') process.exitCode = 2 | |
| 15 | const wire = JSON.stringify(summary) | |
| 16 | if (Buffer.byteLength(wire) + 1 > 16384) throw new RangeError('cargo-fleet-output-limit') | |
| 17 | await printAsync(wire) | |
| 18 | } | |
| 19 | catch { | |
| 20 | process.exitCode = 1 | |
| 21 | try { await printErrorAsync('Cargo fleet simulation unavailable: invalid scenario, execution or output failure') } | |
| 22 | catch { /* A closed diagnostic pipe does not make the failed command succeed. */ } | |
| 23 | } | |
| 24 | }, | |
| 25 | }) | |