@wilm-ai/wilma-cli 0.0.2 → 0.0.3
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/dist/index.js +31 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { emitKeypressEvents } from "node:readline";
|
|
3
3
|
import { select, input, password } from "@inquirer/prompts";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
4
6
|
import { WilmaClient, listTenants, } from "@wilm-ai/wilma-client";
|
|
5
7
|
import { clearConfig, getConfigPath, loadConfig, obfuscateSecret, revealSecret, saveConfig, } from "./config.js";
|
|
6
8
|
// Enable keypress events for escape key detection
|
|
@@ -15,6 +17,15 @@ const ACTIONS = [
|
|
|
15
17
|
];
|
|
16
18
|
async function main() {
|
|
17
19
|
const args = process.argv.slice(2);
|
|
20
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
21
|
+
printUsage();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
25
|
+
const version = await readPackageVersion();
|
|
26
|
+
console.log(version);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
18
29
|
if (args[0] === "config" && args[1] === "clear") {
|
|
19
30
|
await clearConfig();
|
|
20
31
|
console.log(`Cleared config at ${getConfigPath()}`);
|
|
@@ -424,6 +435,20 @@ async function handleCommand(args, config) {
|
|
|
424
435
|
console.log(" wilma messages read <id> [--json]");
|
|
425
436
|
console.log(" wilma exams list [--limit 20] [--student <id|name>] [--all-students] [--json]");
|
|
426
437
|
console.log(" wilma config clear");
|
|
438
|
+
console.log(" wilma --help | -h");
|
|
439
|
+
console.log(" wilma --version | -v");
|
|
440
|
+
}
|
|
441
|
+
function printUsage() {
|
|
442
|
+
console.log("Usage:");
|
|
443
|
+
console.log(" wilma kids list [--json]");
|
|
444
|
+
console.log(" wilma news list [--limit 20] [--student <id|name>] [--all-students] [--json]");
|
|
445
|
+
console.log(" wilma news read <id> [--json]");
|
|
446
|
+
console.log(" wilma messages list [--folder inbox] [--limit 20] [--student <id|name>] [--all-students] [--json]");
|
|
447
|
+
console.log(" wilma messages read <id> [--json]");
|
|
448
|
+
console.log(" wilma exams list [--limit 20] [--student <id|name>] [--all-students] [--json]");
|
|
449
|
+
console.log(" wilma config clear");
|
|
450
|
+
console.log(" wilma --help | -h");
|
|
451
|
+
console.log(" wilma --version | -v");
|
|
427
452
|
}
|
|
428
453
|
async function getProfileForCommandNonInteractive(config, flags) {
|
|
429
454
|
if (!config.lastProfileId) {
|
|
@@ -496,6 +521,12 @@ function parseArgs(args) {
|
|
|
496
521
|
}
|
|
497
522
|
return { command, subcommand, flags };
|
|
498
523
|
}
|
|
524
|
+
async function readPackageVersion() {
|
|
525
|
+
const pkgPath = resolve(dirname(new URL(import.meta.url).pathname), "..", "package.json");
|
|
526
|
+
const raw = await readFile(pkgPath, "utf-8");
|
|
527
|
+
const data = JSON.parse(raw);
|
|
528
|
+
return data.version ?? "unknown";
|
|
529
|
+
}
|
|
499
530
|
async function outputNews(client, opts) {
|
|
500
531
|
const news = await client.news.list();
|
|
501
532
|
const slice = news.slice(0, opts.limit);
|