aboutsummaryrefslogtreecommitdiffstats
path: root/cli.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli.ts')
-rw-r--r--cli.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/cli.ts b/cli.ts
new file mode 100644
index 0000000..eec63d3
--- /dev/null
+++ b/cli.ts
@@ -0,0 +1,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);