@wilm-ai/wilma-cli 0.0.2 → 0.0.4

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 (3) hide show
  1. package/dist/index.js +38 -1
  2. package/package.json +10 -9
  3. package/LICENSE +0 -21
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);
@@ -724,7 +755,13 @@ async function resolveStudentForFlags(profile, config, student) {
724
755
  const match = students.find((s) => fuzzyIncludes(s.name, student));
725
756
  if (match)
726
757
  return match;
727
- return { studentNumber: student, name: student, href: `/!${student}/` };
758
+ // No match found - show available students and exit
759
+ console.error(`Error: No student matching "${student}" found.`);
760
+ if (students.length > 0) {
761
+ console.error("Available students:");
762
+ students.forEach((s) => console.error(` ${s.studentNumber} ${s.name}`));
763
+ }
764
+ process.exit(1);
728
765
  }
729
766
  const stored = config.profiles.find((p) => p.id === config.lastProfileId);
730
767
  if (stored?.lastStudentNumber) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wilm-ai/wilma-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,14 @@
8
8
  "wilmai": "dist/index.js",
9
9
  "wilma": "dist/index.js"
10
10
  },
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "lint": "echo 'add lint'",
14
+ "test": "echo 'add tests'",
15
+ "start": "node dist/index.js",
16
+ "prepack": "pnpm --filter @wilm-ai/wilma-client build && pnpm --filter @wilm-ai/wilma-cli build",
17
+ "test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
18
+ },
11
19
  "dependencies": {
12
20
  "@inquirer/prompts": "^5.3.8",
13
21
  "@wilm-ai/wilma-client": "^0.0.1"
@@ -21,12 +29,5 @@
21
29
  ],
22
30
  "publishConfig": {
23
31
  "access": "public"
24
- },
25
- "scripts": {
26
- "build": "tsc -p tsconfig.json",
27
- "lint": "echo 'add lint'",
28
- "test": "echo 'add tests'",
29
- "start": "node dist/index.js",
30
- "test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
31
32
  }
32
- }
33
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Wilm.ai
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.