1 | # Menehra-CLI
|
2 |
|
3 | a cli plugin for menhera
|
4 |
|
5 | ## Use for CLI Tools
|
6 |
|
7 | ```bash
|
8 | $ yarn global add menhera-cli
|
9 | ```
|
10 |
|
11 | #### Install Template
|
12 |
|
13 | ```bash
|
14 | $ mhr e init:cli
|
15 | ```
|
16 |
|
17 | ```bash
|
18 | $ mhr e init:module
|
19 | ```
|
20 |
|
21 | ## Use For Module
|
22 |
|
23 | ```bash
|
24 | $ yarn add menhera menhera-cli
|
25 | ```
|
26 |
|
27 | #### example
|
28 |
|
29 | ```js
|
30 | // index.js
|
31 | const mhr = require("menhera").default;
|
32 | const CLI = require("menhera-cli");
|
33 |
|
34 | const Foo = CLI({ name: "Foo", version: "0.0.1" });
|
35 |
|
36 | mhr.$use({
|
37 | _mount: {
|
38 | Foo
|
39 | },
|
40 | Foo: {
|
41 | commands: {
|
42 | _: {
|
43 | options: {
|
44 | test: { alias: "t", desc: "test", default: null }
|
45 | },
|
46 | exec({ _, _key, env }) {
|
47 | if (env.NONE_INPUTS) {
|
48 | _.$use({ Foo: { help: _key } });
|
49 | }
|
50 | }
|
51 | },
|
52 | foo: {
|
53 | desc: "Test foo",
|
54 | args: ["foo", "foo1"],
|
55 | examples: {
|
56 | foo: "foo 123"
|
57 | },
|
58 | exec({ foo }) {
|
59 | console.log(foo);
|
60 | }
|
61 | },
|
62 | bar: {
|
63 | desc: "Test bar",
|
64 | args: ["bar"],
|
65 | examples: {
|
66 | bar: "bar 456"
|
67 | },
|
68 | exec({ bar }) {
|
69 | console.log(bar);
|
70 | }
|
71 | }
|
72 | },
|
73 | config: {
|
74 | start: true
|
75 | }
|
76 | }
|
77 | });
|
78 |
|
79 |
|
80 | ```
|
81 |
|
82 | ```bash
|
83 | $ node index.js
|
84 | ```
|
85 |
|
86 | ![preview](./assets/cli.png)
|
87 |
|
88 | ![preview](./assets/examples.png)
|