https://github.com/chainsafe/typescript-cli-generator
A TypeScript CLI Template
https://github.com/chainsafe/typescript-cli-generator
Last synced: 4 months ago
JSON representation
A TypeScript CLI Template
- Host: GitHub
- URL: https://github.com/chainsafe/typescript-cli-generator
- Owner: ChainSafe
- License: apache-2.0
- Created: 2021-02-28T04:49:12.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-08T18:49:18.000Z (almost 5 years ago)
- Last Synced: 2025-10-11T07:09:29.495Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 352 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeScript CLI Template Generator
The template that is used was a port of the [Lodestar CLI](https://github.com/ChainSafe/lodestar/), and thus heavily inspired by the design patters of Lodestar.
### Available Commands
```bash
Commands:
generate Generates the CLI from a template.
config Creates an empty configuration file.
Options:
-h, --help Show help
-v, --version Show version number
```
### Using the generator
The generator requires a configuration file, `config.example.json` is provided as guidance. It can be run as followed:
```bash
npx @chainsafe/ts-cli generate --config ./ -o ./my-cli
```
#### Configuration File
The configuration file follows the following interface pattern:
```TypeScript
interface Config {
name: string; // Name of the CLI
globalOptions: IOption[]; // Options available at the global scope
commands: ICommand[]; // List of commands
}
interface IOption {
name: string; // Name of the option, eg: --
description: string; // Provides a description when --help is used
type: string; // Valid TypeScript type in strings, eg: number
default: string; // The default value
}
interface ICommand {
name: string; // Name of the command
description: string; // Provides a description when --help is used
options: IOption[]; // Options available at the command level
subCommands: ICommand[]; // Optional sub-commands
}
```
#### Modifications
Although there is a lot that can be changed, the bulk of the setup has been done for you. The main things that need updating can be searched for by looking up `// TODO: change this!`. After that, the world is your oyster.
### Roadmap
- [x] Cli generator
- [ ] ?