aboutsummaryrefslogtreecommitdiffstats
path: root/cli.ts
blob: eec63d32df3cab05353bcee39b48585f5f91573e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { parseArgs } from "jsr:@std/cli/parse-args";
import UICVehicle from './lib.ts'

const flags = parseArgs(Deno.args, {
  boolean: ["validate", "json", "text"],
  default: {
    validate: true,
    json: false,
    text: false
  }
});

const uic = new UICVehicle(flags._[0] ?? prompt('\x1b[0;1;32minput: \x1b[0mProvide a UIC wagon number:'), {
  allowMissmatchedReportingMarkCountry: !flags.validate,
  allowUnknownReportingMarkCountry: !flags.validate,
  allowUICCountryUnknown: !flags.validate,
  fetchOperatorFromReportingMark: true,
  validateCheckDigit: flags.validate
})
console.log(flags.json ? JSON.stringify(uic, null, 2) : flags.text ? uic.toString() : uic);