GithubHelp home page GithubHelp logo

tsrpc-cli's Introduction

TSRPC CLI Tools

EN / 中文

CLI utilities for 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

tsrpc-cli's People

Contributors

k8w avatar zhangyuantao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tsrpc-cli's Issues

使用问题,指定了参数但是依然没有输出

命令:
tsrpc encode --verbose -p ./src/shared/protocols/serviceProto.ts -s PtlSend/ReqSend -o ./send.bin {content: 'hello'}

serviceProto.ts是github.com/k8w/tsrpc-examples/chatroom/backend里面的例子

"PtlSend/ReqSend": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "content",
"type": {
"type": "String"
}
}
]
}

命令执行后没有调试信息输出,也没有输出send.bin二进制文件

源代码变更怎么不自动重启

tsrpc dev 启动本地开发服务器,当源代码变更时自动重启
--config 从指定的配置文件读取参数(忽略其它命令行参数)

1.tsrpc dev 这个指令是源代码变更时自动重启, 如果是在生产环境中,怎么做到变更时不自动重启? 如果根据本身的需要选择重启时机。

2.是否可以做到不自动重启,而是热加载变更的文件(例如:修复某个bug)。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.