gunshi 0.26.0 â 0.26.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 +143 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="196" src="./assets/logo.png">
|
|
3
|
+
</p>
|
|
4
|
+
<h1 align="center">đ¯ Gunshi</h1>
|
|
5
|
+
|
|
6
|
+
[![Version][npm-version-src]][npm-version-href]
|
|
7
|
+
[![CI][ci-src]][ci-href]
|
|
8
|
+
[![InstallSize][install-size-src]][install-size-src]
|
|
9
|
+
[![JSR][jsr-src]][jsr-href]
|
|
10
|
+
|
|
11
|
+
Gunshi is a modern javascript command-line library
|
|
12
|
+
|
|
13
|
+
<!-- eslint-disable markdown/no-missing-label-refs -->
|
|
14
|
+
|
|
15
|
+
> [!TIP]
|
|
16
|
+
> gunshi (čģå¸Ģ) is a position in ancient Japanese samurai battle in which a samurai devised strategies and gave orders. That name is inspired by the word "command".
|
|
17
|
+
|
|
18
|
+
<!-- eslint-enable markdown/no-missing-label-refs -->
|
|
19
|
+
|
|
20
|
+
## ⨠Features
|
|
21
|
+
|
|
22
|
+
Gunshi is designed to simplify the creation of modern command-line interfaces:
|
|
23
|
+
|
|
24
|
+
- đ **Simple & Universal**: Run the commands with simple API and support universal runtime.
|
|
25
|
+
- âī¸ **Declarative configuration**: Configure command modules declaratively for better organization and maintainability.
|
|
26
|
+
- đĄī¸ **Type Safe**: TypeScript support with type-safe argument parsing and option resolution by [args-tokens](https://github.com/kazupon/args-tokens)
|
|
27
|
+
- đ§Š **Composable**: Create modular sub-commands that can be composed together for complex CLIs.
|
|
28
|
+
- âŗ **Lazy & Async**: Load command modules lazily and execute them asynchronously for better performance.
|
|
29
|
+
- đ **Auto usage generation**: Generate helpful usage messages automatically for your commands.
|
|
30
|
+
- đ¨ **Custom usage generation**: Customize how usage messages are generated to match your CLI's style.
|
|
31
|
+
- đ **Internationalization**: Support multiple languages with built-in i18n, locale resource lazy loading and i18n library integration.
|
|
32
|
+
|
|
33
|
+
## đŋ Installation
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
# npm
|
|
37
|
+
npm install --save gunshi
|
|
38
|
+
|
|
39
|
+
## pnpm
|
|
40
|
+
pnpm add gunshi
|
|
41
|
+
|
|
42
|
+
## yarn
|
|
43
|
+
yarn add gunshi
|
|
44
|
+
|
|
45
|
+
## deno
|
|
46
|
+
deno add jsr:@kazupon/gunshi
|
|
47
|
+
|
|
48
|
+
## bun
|
|
49
|
+
bun add gunshi
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## đ Usage
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import { cli } from 'gunshi'
|
|
56
|
+
|
|
57
|
+
// define a command with declarative configuration, using commandable object
|
|
58
|
+
const command = {
|
|
59
|
+
name: 'greet',
|
|
60
|
+
description: 'A greeting command',
|
|
61
|
+
options: {
|
|
62
|
+
name: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
short: 'n',
|
|
65
|
+
description: 'Name to greet'
|
|
66
|
+
},
|
|
67
|
+
greeting: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
short: 'g',
|
|
70
|
+
default: 'Hello',
|
|
71
|
+
description: 'Greeting to use (default: "Hello")'
|
|
72
|
+
},
|
|
73
|
+
times: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
short: 't',
|
|
76
|
+
default: 1,
|
|
77
|
+
description: 'Number of times to repeat the greeting (default: 1)'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
run: ctx => {
|
|
81
|
+
const { name = 'World', greeting, times } = ctx.values
|
|
82
|
+
for (let i = 0; i < times; i++) {
|
|
83
|
+
console.log(`${greeting}, ${name}!`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// run a command that is defined above
|
|
89
|
+
// (the 3rd argument of `cli` is the command option)
|
|
90
|
+
await cli(process.argv.slice(2), command, {
|
|
91
|
+
name: 'my-app',
|
|
92
|
+
version: '1.0.0',
|
|
93
|
+
description: 'My CLI application'
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
About more details and usage, see [documentations](https://gunshi.dev)
|
|
98
|
+
|
|
99
|
+
## đââī¸ Showcases
|
|
100
|
+
|
|
101
|
+
- [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
|
|
102
|
+
- [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
|
|
103
|
+
- [curxy](https://github.com/ryoppippi/curxy): An proxy worker for using ollama in cursor
|
|
104
|
+
- [SiteMCP](https://github.com/ryoppippi/sitemcp): Fetch an entire site and use it as an MCP Server
|
|
105
|
+
|
|
106
|
+
## đ Contributing guidelines
|
|
107
|
+
|
|
108
|
+
If you are interested in contributing to `gunshi`, I highly recommend checking out [the contributing guidelines](/CONTRIBUTING.md) here. You'll find all the relevant information such as [how to make a PR](/CONTRIBUTING.md#pull-request-guidelines), [how to setup development](/CONTRIBUTING.md#development-setup)) etc., there.
|
|
109
|
+
|
|
110
|
+
## đ Credits
|
|
111
|
+
|
|
112
|
+
This project is inspired and powered by:
|
|
113
|
+
|
|
114
|
+
- [`citty`](https://github.com/unjs/citty), created by [UnJS team](https://github.com/unjs) and contributors
|
|
115
|
+
- [`ordana`](https://github.com/sapphi-red/ordana), createdy by [sapphi-red](https://github.com/sapphi-red), inspired documentation generation
|
|
116
|
+
- cline and claude 3.7 sonnet, examples and docs is generated
|
|
117
|
+
|
|
118
|
+
Thank you!
|
|
119
|
+
|
|
120
|
+
## đ¤ Sponsors
|
|
121
|
+
|
|
122
|
+
The development of Gunshi is supported by my OSS sponsors!
|
|
123
|
+
|
|
124
|
+
<p align="center">
|
|
125
|
+
<a href="https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg">
|
|
126
|
+
<img src='https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg'/>
|
|
127
|
+
</a>
|
|
128
|
+
</p>
|
|
129
|
+
|
|
130
|
+
## ÂŠī¸ License
|
|
131
|
+
|
|
132
|
+
[MIT](http://opensource.org/licenses/MIT)
|
|
133
|
+
|
|
134
|
+
<!-- Badges -->
|
|
135
|
+
|
|
136
|
+
[npm-version-src]: https://img.shields.io/npm/v/gunshi?style=flat
|
|
137
|
+
[npm-version-href]: https://npmjs.com/package/gunshi
|
|
138
|
+
[jsr-src]: https://jsr.io/badges/@kazupon/gunshi
|
|
139
|
+
[jsr-href]: https://jsr.io/@kazupon/gunshi
|
|
140
|
+
[install-size-src]: https://pkg-size.dev/badge/install/72346
|
|
141
|
+
[install-size-href]: https://pkg-size.dev/gunshi
|
|
142
|
+
[ci-src]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml/badge.svg
|
|
143
|
+
[ci-href]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml
|