protodec/README.md

99 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2019-09-19 15:06:15 +00:00
# protodec
2019-09-20 21:04:21 +00:00
Command-line tool to encode and decode arbitrary protobuf data.
2019-09-19 15:06:15 +00:00
2021-11-29 21:52:01 +00:00
## Installation
2021-11-29 21:52:47 +00:00
This program requires Crystal. See: https://crystal-lang.org/install/
2021-11-29 21:52:01 +00:00
### Standalone
1. Clone: `git clone https://github.com/iv-org/protodec && cd protodec`
2. Build: `crystal build src/protodec.cr`
3. See [Usage](#Usage) below
### As a Crystal library
Add this to your application's `shard.yml`:
```yaml
dependencies:
protodec:
github: iv-org/protodec
2022-11-30 23:08:30 +00:00
version: ~> 0.1.5
2021-11-29 21:52:01 +00:00
```
2019-09-19 15:06:15 +00:00
## Usage
```
$ ./protodec -h
Usage: protodec [arguments]
2019-09-20 21:05:36 +00:00
Command-line encoder and decoder for arbitrary protobuf data. Reads from standard input.
-e, --encode Encode input
-d, --decode Decode input (default)
-b, --base64 STDIN is Base64-encoded
2019-09-19 15:06:15 +00:00
-x, --hex STDIN is space-separated hexstring
2019-09-20 21:05:36 +00:00
-r, --raw STDIN is raw binary data (default)
2019-09-19 15:06:15 +00:00
-p, --pretty Pretty print output
-h, --help Show this help
```
```
2019-09-20 21:05:36 +00:00
$ echo 'CkEKCeOCj+OBn+OBlxDSCSIQWmQ730+N8z8tsp3vp8YJQCoSCAESBzA4MDAwMDAaBQ26sSZEKgsIARIHMDgwMDAwMBXD9UhA' | ./protodec -bp
2019-09-19 15:06:15 +00:00
{
2019-09-20 21:05:36 +00:00
"1:0:embedded": {
"1:0:string": "わたし",
"2:1:varint": 1234,
"4:2:bytes": [
2019-09-19 15:06:15 +00:00
90,
100,
59,
223,
79,
141,
243,
63,
45,
178,
157,
239,
167,
198,
9,
64
],
2019-09-20 21:05:36 +00:00
"5:3:embedded": {
"1:0:varint": 1,
"2:1:string": "0800000",
"3:2:embedded": {
"1:0:float32": 666.7769775390625
2019-09-19 15:06:15 +00:00
}
},
2019-09-20 21:05:36 +00:00
"5:4:embedded": {
"1:0:varint": 1,
"2:1:string": "0800000"
2019-09-19 15:06:15 +00:00
}
},
2019-09-20 21:05:36 +00:00
"2:1:float32": 3.140000104904175
2019-09-19 15:06:15 +00:00
}
```
2021-08-11 15:39:38 +00:00
## Windows
Windows users can run the binaries in a linux-on-windows tool (like Git bash or WSL) or use the official [protobuf binaries](https://github.com/protocolbuffers/protobuf/releases) to encode/decode protobuf data.
2019-09-19 15:06:15 +00:00
## Contributing
2021-11-29 21:52:01 +00:00
1. Fork it (<https://github.com/iv-org/protodec/fork>)
2019-09-19 15:06:15 +00:00
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Omar Roth](https://github.com/omarroth) - creator and maintainer