# tsrpc-cli

> TSRPC CLI Tools

Latest version **2.4.5** (published 2022-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsrpc-cli
pnpm add tsrpc-cli
yarn add tsrpc-cli
bun add tsrpc-cli
```

Provides the commands `tsrpc`, `tsrpc-cli`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.5 |
| Published | 2022-07-03 |
| First published | 2019-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 141.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | k8w |
| Maintainers | k8w |
| Keywords | tsrpc, tsbuffer, k8w, typescript, buffer, protobuf |

## Links

- npm: https://www.npmjs.com/package/tsrpc-cli
- Repository: https://github.com/k8w/tsrpc-cli
- Homepage: https://github.com/k8w/tsrpc-cli#readme
- Issues: https://github.com/k8w/tsrpc-cli/issues
- npm.io page: https://npm.io/package/tsrpc-cli

## Dependencies (16)

- [ora](https://npm.io/package/ora.md) ^5.4.1
- [glob](https://npm.io/package/glob.md) ^7.2.3
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [ts-node](https://npm.io/package/ts-node.md) ^10.8.2
- [chokidar](https://npm.io/package/chokidar.md) ^3.5.3
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.2.4
- [minimist](https://npm.io/package/minimist.md) ^1.2.6
- [tsbuffer](https://npm.io/package/tsbuffer.md) ^2.2.3
- [os-locale](https://npm.io/package/os-locale.md) ^5.0.0
- [typescript](https://npm.io/package/typescript.md) ^4.7.4
- [tsrpc-proto](https://npm.io/package/tsrpc-proto.md) ^1.4.2
- [tsbuffer-schema](https://npm.io/package/tsbuffer-schema.md) ^2.2.0
- [k8w-extend-native](https://npm.io/package/k8w-extend-native.md) ^1.4.6
- [typescript-formatter](https://npm.io/package/typescript-formatter.md) ^7.2.2
- [tsbuffer-proto-generator](https://npm.io/package/tsbuffer-proto-generator.md) ^1.7.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.4.5 (latest) — 2022-07-03
- 2.4.6-dev.1 (dev) — 2023-06-07
- 2.4.6-dev.0 — 2023-06-07
- 2.4.5-dev.2 — 2022-07-03
- 2.4.5-dev.1 — 2022-07-03
- 2.4.5-dev.0 — 2022-07-03
- 2.4.4 — 2022-06-14
- 2.4.4-dev.0 — 2022-06-10
- 2.4.3 — 2022-04-28
- 2.4.3-dev.5 — 2022-04-28
- 2.4.3-dev.4 — 2022-04-28
- 2.4.3-dev.3 — 2022-04-28
- 2.4.3-dev.2 — 2022-04-28
- 2.4.3-dev.1 — 2022-04-18
- 2.4.3-dev.0 — 2022-04-18
- … 77 more at https://npm.io/package/tsrpc-cli/versions

## README

TSRPC CLI Tools
===

EN / [中文](README_CN.md)

CLI utilities for [TSRPC](https://npmjs.com/tsrpc) 

# Install
```
npm i -g tsrpc-cli
```

## Usage
### Development Utilities
```
tsrpc proto <options>                Generate proto file
    --config <file>                     Read params from config file (would ignore all other CLI params)
    -i, --input <file>                  Input TS file (support glob expression)
                                        It would generate all exported types
    -o, --output <file>                 Output file (or print to CLI)
    -c, --compatible <file>             Compatible mode, compatible to old proto (=output by default)
    --new                               Generate fresh new proto (no compatible)
    --ugly                              Output as ugly JSON (no indent and smaller)
    --verbose                           Show debug info
    --ignore <glob>                     Files to be ignored from --input

tsrpc api <options>                  Generate TSRPC API implementations
    --config <file>                     Read params from config file (would ignore all other CLI params)
    -i, --input <file>                  Proto file path (proto.ts or proto.json)
    -o, --output <folder>               Output api folder path

tsrpc sync                           Sync directory content as readonly
    --config <file>                     Read params from config file (would ignore all other CLI params)
    --from <dir>                        Source path
    --to <dir>                          Target path (copy and set as read-only)

tsrpc link <options>                 Create symlink (cross all operating system)
    --config <file>                     Read params from config file (would ignore all other CLI params)
    --from <dir>                        Source path
    --to <dir>                          Target path for created symlink

tsrpc dev <options>                  Run local dev server
    --config <file>                     Read params from config file (would ignore all other CLI params)

tsrpc build <options>                Build the server project
    --config <file>                     Read params from config file (would ignore all other CLI params)
```

### Buffer Utilities

```
tsrpc encode <options> [exp]         Encode a JS expression or a file (content is JS expression)
    [exp]                               Expression to encode (e.g. "123" "new Uint8Array([1,2,3])")
    -p, --proto <file>                  Proto file to use
    -s, --schema <id>                   SchemaID (filePath/TypeName)
    -i, --input <file>                  Input file path, alternative to [exp]
    -o, --output <file>                 Output file path (or print to CLI)
    --verbose                           Show debug info
                                        
tsrpc decode <options> [binstr]      Decode buffer
    [binstr]                            Buffer to decode, hex string, like "0F A2 E3"
    -p, --proto <file>                  Proto file
    -s, --schema <id>                   SchemaID (filePath/TypeName)
    -i, --input <file>                  Input file path, alternative to [binstr]
    -o, --output <file>                 Output file path (or print to CLI)
    --verbose                           Show debug info

tsrpc validate <options> [exp]       Validate if a JS expression is valid to a schema
    [exp]                               Expression to validate (e.g. "123" "new Uint8Array([1,2,3])")
    -p, --proto <file>                  Proto file to use
    -s, --schema <id>                   SchemaID (filePath/TypeName)
    -i, --input <file>                  Input file path, alternative to [exp]

tsrpc show <file>                    Show a binary file as hex string
```

## Examples

### Use Config File
```
tsrpc proto --config tsrpc.config.ts
tsrpc api   --config tsrpc.config.ts
tsrpc sync  --config tsrpc.config.ts
tsrpc link  --config tsrpc.config.ts
tsrpc dev   --config tsrpc.config.ts
tsrpc build --config tsrpc.config.ts
```

### Generate Proto
```
tsrpc proto -i shared/protocols -o shared/protocols/proto.ts
```

### Encode Test
```
tsrpc encode -p proto.json -s a/b/c/TypeName "{value: 1}"
tsrpc encode -p proto.ts -s a/b/c/TypeName "{value: 1}" -o buf.bin 
```

### Decode Test
```
tsrpc decode -p proto.json -s a/b/c/TypeName "01 0A 01"
tsrpc decode -p proto.json -s a/b/c/TypeName -i buf.bin
```

### Validation Test
```
tsrpc validate -p proto.json -s a/b/c/TypeName "{value: 1}"
tsrpc validate -p proto.json -s a/b/c/TypeName -i value.js
```

### Show Buffer Content
```
tsrpc show buf.bin
```

---
_Source: https://npm.io/package/tsrpc-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
