Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/h-a-n-a/pero
π Easy to use route-based tool for building large-scale command-line interfaces
https://github.com/h-a-n-a/pero
cli command-line node typescript
Last synced: 12 days ago
JSON representation
π Easy to use route-based tool for building large-scale command-line interfaces
- Host: GitHub
- URL: https://github.com/h-a-n-a/pero
- Owner: h-a-n-a
- License: mit
- Created: 2021-07-09T14:37:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-08T09:54:23.000Z (over 3 years ago)
- Last Synced: 2024-11-01T11:42:40.074Z (19 days ago)
- Topics: cli, command-line, node, typescript
- Language: TypeScript
- Homepage:
- Size: 63.5 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Pero
Route based CLI tool for creating large scale command line interfaces.
## Why?
Nowadays, we have commander.js and all the other cli tools to choose, but why we build **yet another cli tool** ?
In the real-world scenario, nested commands are so popular among large-scale projects. Pero is trying to solve this problem and also bring you with the progressive TypeScript support.
## Feature
- Route based, born to create nested CLI commands
- ESBuild driven, really fast to compile your CLI project## Quick Tour
**This project is under heavy development, APIs might be changed until the stable version is released. [πRoadmap](https://github.com/h-a-n-a/pero/issues/1)**
### 1. Install
```bash
npm install pero --save
# or use
yarn add pero
```### 2. Create a folder for CLI
```bash
mkdir src
cd $_
touch index.ts # or index.js
```In the example above, `index.ts` is created in the root of the CLI source folder `src`,
which is defined as the top-most command in CLI.```
.
βββ src
βββ index.ts
```### 3. `vim index.ts`
Add the code and finish your first Pero app!
```typescript
import { Command, Args } from 'pero'export default (command: Command) => {
// command registration: define your command here
command
.argument('[something]', 'your-description')
.option('-e', 'environment')// action
return (args: Args) => {
// do something with user-input args here
command.help() // print help message
}
}
```In Pero, we have to two steps in our runtime:
- Step1: Registration, in the outer callback we have `command` passed as the first param, you can utilize this to define your command's arguments or options.
- Step2: Action, in the inner callback we have `args` passed to, you may do something with user-input args### 4. Compile and run
```bash
npx pero src --name "name-your-cli"
```Your CLI will be emitted to `dist`
Run the code below, you will get the corresponding help message in the terminal.
```bash
node ./dist/pero.js
```## Advanced Usage
### Nested Command
With the demo project introduced in the Quick Tour section, try to add a new folder under `src` folder,
you will get the nested command right away! This is really cool.```
.
βββ src
βββ build ## the sub-command we added
β βββ index.ts
βββ index.ts
```To trigger the sub-command `build`, do the compilation first and run:
```bash
node ./dist/index.js build
```You will see anything in the sub-command's action printed to the screen. Great!
## πRoadmap
This project is under heavy development, you may refer to [this](https://github.com/h-a-n-a/pero/issues/1) to get the latest update!
## Acknowledgement
Special thanks to @yisar132 for the logo, it's great!
## LICENSE
[MIT](./LICENSE) License Β© 2021 [H](https://github.com/h-a-n-a)