papagaio 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/cli.js +22 -2
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -1,10 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
  import { Papagaio } from "./papagaio.js";
3
3
  import fs from "fs";
4
+ import { createRequire } from "module";
5
+ const require = createRequire(import.meta.url);
6
+ const pkg = require("./package.json");
4
7
 
5
- const file = process.argv[2];
8
+
9
+ // Help & Version
10
+ const args = process.argv.slice(2);
11
+ if (args.includes("-v") || args.includes("--version")) {
12
+ console.log(pkg.version);
13
+ process.exit(0);
14
+ }
15
+ if (args.includes("-h") || args.includes("--help")) {
16
+ console.log(`Usage: papagaio [options] <file>
17
+
18
+ Options:
19
+ -h, --help Show this help message
20
+ -v, --version Show version number`);
21
+ process.exit(0);
22
+ }
23
+
24
+ // File input
25
+ const file = args.find(arg => !arg.startsWith("-"));
6
26
  if (!file) {
7
- console.error("usage: papagaio <file>");
27
+ console.error("Error: no input file specified.\nUse --help for usage.");
8
28
  process.exit(1);
9
29
  }
10
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "papagaio",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "easy yet powerful preprocessor",
5
5
  "main": "papagaio.js",
6
6
  "type": "module",