papagaio 0.5.2 → 0.6.2
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/README.md +242 -85
- package/bin/cli.mjs +153 -0
- package/examples/simple.html +2 -2
- package/examples/wasm.papagaio +70 -0
- package/index.html +12 -3
- package/package.json +7 -3
- package/src/papagaio-bootstrap.mjs +3 -5
- package/src/papagaio.js +64 -83
- package/tests/tests.json +35 -35
- package/bin/cli.js +0 -34
- package/bin/cli.qjs +0 -57
package/bin/cli.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Papagaio } from "../src/papagaio.js";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import { createRequire } from "module";
|
|
5
|
-
const require = createRequire(import.meta.url);
|
|
6
|
-
const pkg = require("../package.json");
|
|
7
|
-
|
|
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("-"));
|
|
26
|
-
if (!file) {
|
|
27
|
-
console.error("Error: no input file specified.\nUse --help for usage.");
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const src = fs.readFileSync(file, "utf8");
|
|
32
|
-
const p = new Papagaio();
|
|
33
|
-
const out = p.process(src);
|
|
34
|
-
console.log(out);
|
package/bin/cli.qjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env qjs
|
|
2
|
-
import * as std from "std";
|
|
3
|
-
import * as os from "os";
|
|
4
|
-
|
|
5
|
-
// Import Papagaio class - ajuste o caminho conforme necessário
|
|
6
|
-
// Para QuickJS, você pode incluir o arquivo diretamente ou usar import
|
|
7
|
-
import { Papagaio } from "../src/papagaio.js";
|
|
8
|
-
|
|
9
|
-
// Version (você pode hardcoded ou ler de um arquivo JSON se necessário)
|
|
10
|
-
const VERSION = "1.0.0";
|
|
11
|
-
|
|
12
|
-
// Parse command line arguments
|
|
13
|
-
const args = scriptArgs.slice(1); // QuickJS usa scriptArgs ao invés de process.argv
|
|
14
|
-
|
|
15
|
-
// Help & Version
|
|
16
|
-
if (args.includes("-v") || args.includes("--version")) {
|
|
17
|
-
std.out.puts(VERSION + "\n");
|
|
18
|
-
std.exit(0);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (args.includes("-h") || args.includes("--help")) {
|
|
22
|
-
std.out.puts(`Usage: papagaio [options] <file>
|
|
23
|
-
Options:
|
|
24
|
-
-h, --help Show this help message
|
|
25
|
-
-v, --version Show version number
|
|
26
|
-
`);
|
|
27
|
-
std.exit(0);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// File input
|
|
31
|
-
const file = args.find(arg => !arg.startsWith("-"));
|
|
32
|
-
if (!file) {
|
|
33
|
-
std.err.puts("Error: no input file specified.\nUse --help for usage.\n");
|
|
34
|
-
std.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Read file
|
|
38
|
-
let src;
|
|
39
|
-
try {
|
|
40
|
-
const f = std.open(file, "r");
|
|
41
|
-
if (!f) {
|
|
42
|
-
std.err.puts(`Error: cannot open file '${file}'\n`);
|
|
43
|
-
std.exit(1);
|
|
44
|
-
}
|
|
45
|
-
src = f.readAsString();
|
|
46
|
-
f.close();
|
|
47
|
-
} catch (e) {
|
|
48
|
-
std.err.puts(`Error reading file: ${e}\n`);
|
|
49
|
-
std.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Process with Papagaio
|
|
53
|
-
const p = new Papagaio();
|
|
54
|
-
const out = p.process(src);
|
|
55
|
-
|
|
56
|
-
// Output result
|
|
57
|
-
std.out.puts(out);
|