papagaio 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +19 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Papagaio } from "./papagaio.js";
|
|
3
3
|
import fs from "fs";
|
|
4
|
+
import pkg from "./package.json" assert { type: "json" };
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Help & Version
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
if (args.includes("-v") || args.includes("--version")) {
|
|
9
|
+
console.log(pkg.version);
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
13
|
+
console.log(`Usage: papagaio [options] <file>
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
-h, --help Show this help message
|
|
17
|
+
-v, --version Show version number`);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// File input
|
|
22
|
+
const file = args.find(arg => !arg.startsWith("-"));
|
|
6
23
|
if (!file) {
|
|
7
|
-
console.error("
|
|
24
|
+
console.error("Error: no input file specified.\nUse --help for usage.");
|
|
8
25
|
process.exit(1);
|
|
9
26
|
}
|
|
10
27
|
|