@keshavsoft/kschema-cli 1.9.2 → 1.9.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.
@@ -2,10 +2,11 @@ import init from "../commands/init.js";
2
2
  import test from "../commands/test.js";
3
3
  import generateSamples from "../commands/generateSamples.js";
4
4
 
5
+ // resolveCommand.js
5
6
  const map = {
6
7
  init,
7
8
  test,
8
- generateSamples
9
+ "generate-samples": generateSamples
9
10
  };
10
11
 
11
12
  export default function resolveCommand(cmd) {
package/bin/v9/start.js CHANGED
@@ -1,23 +1,63 @@
1
1
  import parseInput from "./core/parseInput.js";
2
2
  import resolveCommand from "./core/resolveCommand.js";
3
3
 
4
+ /*
5
+ KSchema CLI – Entry Flow
6
+
7
+ 1. Read user input from terminal (parseInput)
8
+ 2. If no command → show usage (first-time user safety)
9
+ 3. If help flags → show usage (quick guidance)
10
+ 4. Resolve command dynamically (no hardcoding logic)
11
+ 5. If command not found → inform + guide back to usage
12
+ 6. Execute command with parsed input
13
+
14
+ Goal:
15
+ - Zero confusion for user
16
+ - Single source of truth (showUsage)
17
+ - Easy to extend (just add commands, no core changes)
18
+ */
19
+
4
20
  const run = async () => {
5
21
  const input = parseInput();
6
22
 
7
- if (!input.cmd) {
8
- console.log("Usage: kschema <init|test> [args]");
9
- return;
10
- }
23
+ if (!input.cmd) return showUsage();
24
+
25
+ if (input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") return showUsage();
11
26
 
12
27
  const command = resolveCommand(input.cmd);
13
28
 
14
- if (!command) {
15
- console.log(`Unknown command: ${input.cmd}`);
16
- console.log("Usage: kschema <init|test> [args]");
17
- return;
18
- };
29
+ if (!command) return (console.log(`Unknown command: ${input.cmd}\n`), showUsage());
19
30
 
20
31
  await command(input);
21
32
  };
22
33
 
23
- export default run;
34
+ export default run;
35
+
36
+ const showUsage = () => {
37
+ const g = "\x1b[32m";
38
+ const y = "\x1b[33m";
39
+ const c = "\x1b[36m";
40
+ const gray = "\x1b[90m";
41
+ const r = "\x1b[0m";
42
+
43
+ console.log(`
44
+ ${c}🚀 KSchema CLI v1.9.3${r}
45
+
46
+ ${y}Usage:${r}
47
+ ${g}npx @keshavsoft/kschema-cli${r} <command> [options]
48
+
49
+ // inside showUsage()
50
+ ${y}Commands:${r}
51
+ ${g}init${r} 🛠 Initialize a new schema setup
52
+ ${g}test${r} ✅ Run schema validations/tests
53
+ ${g}generate-samples${r} 📦 Generate sample schema files
54
+
55
+ ${y}Examples:${r}
56
+ ${gray}npx @keshavsoft/kschema-cli init${r}
57
+ ${gray}npx @keshavsoft/kschema-cli test users${r}
58
+
59
+ ${y}Tip:${r}
60
+ 💡 npm i -g @keshavsoft/kschema-cli
61
+ ${g}kschema${r} <command>
62
+ `);
63
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keshavsoft/kschema-cli",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "CLI to scaffold projects using templates",
5
5
  "keywords": [
6
6
  "cli",