also looking at this
feat: run configured modeled cargo delivery and phase failures
#97
38 files
+2114
-30
| @@ -0,0 +1,23 @@ | ||
| 1 | import { defineCommand } from '@stacksjs/cli' | |
| 2 | import { printAsync, printErrorAsync } from '../../resources/functions/cli/output' | |
| 3 | import { cargoDeliveryScenarios, cargoDeliverySummary, simulateCargoDelivery } from '../../resources/functions/drone/cargo/delivery' | |
| 4 | ||
| 5 | export default defineCommand({ | |
| 6 | name: 'cargo:deliver', | |
| 7 | description: 'Simulate owned cargo release, modeled recipient evidence and a finite alternate landing', | |
| 8 | options: { | |
| 9 | '--scenario <name>': { description: cargoDeliveryScenarios.join(', '), default: 'nominal' }, | |
| 10 | }, | |
| 11 | async handle(options) { | |
| 12 | try { | |
| 13 | const summary = cargoDeliverySummary(simulateCargoDelivery({ scenario: options.scenario })) | |
| 14 | if (!summary.demonstrationMatched) process.exitCode = 1 | |
| 15 | await printAsync(JSON.stringify(summary)) | |
| 16 | } | |
| 17 | catch { | |
| 18 | process.exitCode = 1 | |
| 19 | try { await printErrorAsync('Cargo delivery simulation failed: invalid input, unavailable result or output failure') } | |
| 20 | catch { /* Closed stderr cannot turn a failed output into success. */ } | |
| 21 | } | |
| 22 | }, | |
| 23 | }) | |