convoker 0.6.1 → 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.
Files changed (2) hide show
  1. package/README.md +67 -29
  2. package/package.json +9 -5
package/README.md CHANGED
@@ -1,34 +1,72 @@
1
1
  # Convoker
2
2
 
3
- A simple, type safe CLI library for TypeScript.
3
+ Convoker is a simple, type-safe CLI framework for TypeScript. It provides several components that can help you build command line interfaces.
4
+
5
+ ## Modules
6
+
7
+ Each module can be installed independently, or simply with the [convoker](https://www.npmjs.com/package/convoker) package.
8
+
9
+ ### [Core](https://www.npmjs.com/package/@convoker/core)
10
+
11
+ A customizable CLI argument parser.
12
+
13
+ ```ts
14
+ import { Command, i, parsers, middleware } from "convoker";
15
+
16
+ export default new Command("greet")
17
+ .description()
18
+ .input({
19
+ names: i.positional("string").list().optional(),
20
+ })
21
+ .use(middleware.versionFlag(), middleware.helpFlag())
22
+ .use(async (input, next) => {
23
+ // Middleware logic
24
+ return next();
25
+ })
26
+ .action(async ({ names }) => {
27
+ names.forEach((name) => {
28
+ console.log(`Hello, ${name}!`);
29
+ });
30
+ });
31
+ ```
32
+
33
+ ## [Prompt](https://www.npmjs.com/package/@convoker/prompt)
34
+
35
+ A customizable CLI prompting library.
36
+
37
+ ```ts
38
+ import { prompt } from "convoker";
39
+
40
+ const confirmation = await prompt.confirm({
41
+ message: "Are you sure you want to proceed?",
42
+ });
43
+ if (!confirmation) return;
44
+
45
+ const username = await prompt.text({ message: "Username" });
46
+ const password = await prompt.password({ message: "Password" });
47
+ // You can also have editors, searching and selecting.
48
+ ```
49
+
50
+ ### [Log](https://www.npmjs.com/package/@convoker/log)
51
+
52
+ A logging library, with several logging levels and customizable messages.
53
+
54
+ ```ts
55
+ import { log } from "convoker";
56
+
57
+ log.trace("Debug information");
58
+ log.info("Information");
59
+ log.warn("Warning");
60
+ log.error("Error");
61
+ log.fatal("Fatal");
62
+ ```
63
+
64
+ ### [Theme](https://www.npmjs.com/package/@convoker/theme)
65
+
66
+ An ANSI coloring library, as well as theme definitions for core, logging and prompting.
4
67
 
5
68
  ```ts
6
- import { i, Command } from "convoker";
7
-
8
- const program = new Command("calc").description("A basic calculator.");
9
-
10
- program
11
- .subCommand("add", (c) =>
12
- c
13
- .description("Adds two numbers.")
14
- .input({
15
- x: i.option("number", "-x", "--x"),
16
- y: i.option("number", "-y", "--y"),
17
- })
18
- .action(({ x, y }) => {
19
- console.log(`${x} + ${y} = ${x + y}`);
20
- }),
21
- )
22
- .subCommand("sub", (c) =>
23
- c
24
- .description("Subtracts any amount of numbers.")
25
- .input({
26
- numbers: i.option("number", "--numbers", "-n").list(),
27
- })
28
- .action(({ numbers }) => {
29
- const sub = numbers.reduce((a, b) => a - b, 0);
30
- console.log(`${numbers.join(" + ")} = ${sub}`);
31
- }),
32
- )
33
- .run();
69
+ import { theme } from "convoker";
70
+
71
+ console.log(`${theme.bold("Hello,")} ${theme.green("World!")}`);
34
72
  ```
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "convoker",
3
3
  "type": "module",
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "description": "A simple, type-safe CLI framework.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/sprucepad/convoker"
9
+ },
6
10
  "exports": {
7
11
  ".": {
8
12
  "types": "./dist/index.d.mts",
@@ -25,10 +29,10 @@
25
29
  "dist"
26
30
  ],
27
31
  "dependencies": {
28
- "@convoker/core": "^0.3.1",
29
- "@convoker/prompt": "^0.3.1",
30
- "@convoker/log": "^0.1.3",
31
- "@convoker/theme": "^0.1.2"
32
+ "@convoker/core": "^0.3.2",
33
+ "@convoker/prompt": "^0.3.2",
34
+ "@convoker/theme": "^0.1.3",
35
+ "@convoker/log": "^0.1.4"
32
36
  },
33
37
  "devDependencies": {
34
38
  "@types/node": "~22.15.27",