@xingchuan-qxc/fmcli 1.0.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.
- package/README.md +115 -0
- package/dist/bin/fmcli +3552 -0
- package/dist/bin/fmcli.cmd +2 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# fmcli
|
|
2
|
+
|
|
3
|
+
A flexible, module-driven CLI framework. Define your own modules (JSON or TypeScript) and run them as first-class subcommands — no forking, no boilerplate.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @xingchuan-qxc/fmcli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Set your API host
|
|
15
|
+
fmcli config api-host set <url>
|
|
16
|
+
|
|
17
|
+
# Log in
|
|
18
|
+
fmcli login
|
|
19
|
+
|
|
20
|
+
# See available commands (built-in + your modules)
|
|
21
|
+
fmcli --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Modules
|
|
25
|
+
|
|
26
|
+
fmcli discovers modules from `~/.fmcli/modules/` at startup. Each module is a self-contained `.ts` or `.json` file that registers one or more CLI subcommands.
|
|
27
|
+
|
|
28
|
+
### TypeScript module
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// ~/.fmcli/modules/hello/hello.ts
|
|
32
|
+
export default {
|
|
33
|
+
command: "hello",
|
|
34
|
+
description: "Say hello",
|
|
35
|
+
register(cmd, ctx) {
|
|
36
|
+
cmd.option("--name <name>", "Who to greet", "world");
|
|
37
|
+
cmd.action((opts) => {
|
|
38
|
+
console.log(`Hello, ${opts.name}!`);
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### JSON module
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"command": "my-query",
|
|
49
|
+
"description": "Run a custom query",
|
|
50
|
+
"sql": "SELECT COUNT(*) AS total FROM my_table WHERE place_id = :placeId",
|
|
51
|
+
"params": {
|
|
52
|
+
"placeId": { "source": "context", "field": "warehouseId" }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Module directories
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
fmcli config dirs # show module directories
|
|
61
|
+
fmcli config dirs add <path> # add a directory
|
|
62
|
+
fmcli config dirs remove <path>
|
|
63
|
+
fmcli config modules # list all registered modules
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Version-based conflict resolution
|
|
67
|
+
|
|
68
|
+
When multiple directories contain a module with the same command name, the highest `version` wins. Same version — later directory wins.
|
|
69
|
+
|
|
70
|
+
## Syncing modules
|
|
71
|
+
|
|
72
|
+
Back up and share modules via OSS:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
fmcli sync push # upload your modules
|
|
76
|
+
fmcli sync pull # download your modules (cross-machine restore)
|
|
77
|
+
fmcli sync pull --user bob # pull a teammate's modules
|
|
78
|
+
fmcli sync ls # list remote modules
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Commands
|
|
82
|
+
|
|
83
|
+
All commands are discoverable via `--help`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
fmcli --help
|
|
87
|
+
fmcli login --help
|
|
88
|
+
fmcli config --help
|
|
89
|
+
fmcli sync --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Built-in commands
|
|
93
|
+
|
|
94
|
+
| Command | Description |
|
|
95
|
+
|---------|-------------|
|
|
96
|
+
| `login` | OAuth login (opens browser) |
|
|
97
|
+
| `login status` | Show current login status |
|
|
98
|
+
| `login logout` | Revoke token and log out |
|
|
99
|
+
| `config` | Manage configuration |
|
|
100
|
+
| `sync` | Sync modules to/from OSS |
|
|
101
|
+
| `update` | Self-upgrade to latest version |
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
Configuration is stored at `~/.fmcli/config.json`:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
fmcli config api-host set <url> # set API host
|
|
109
|
+
fmcli config api-host show # show current API host
|
|
110
|
+
fmcli config dirs # manage module directories
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|