Compare commits

...

8 commits

Author SHA1 Message Date
Samantaz Fox
9e02d88a19 Release v0.1.5 2022-12-01 00:08:30 +01:00
Samantaz Fox
c6cede69e6 cast_json: enforce param type at compile time 2022-12-01 00:07:22 +01:00
Samantaz Fox
11813ae363
Fix typo in README 2021-11-29 22:52:47 +01:00
Samantaz Fox
618a336060
Update README.md 2021-11-29 22:52:01 +01:00
TheFrenchGhosty
7de78da0f8
Add a section about windows 2021-08-11 17:39:38 +02:00
syeopite
f30f2abfde
Bump version 2021-05-24 06:36:14 -07:00
Omar Roth
aace6fbbbd
Bump version 2020-04-09 12:19:32 -05:00
Omar Roth
e9df06c262
Update dependencies 2020-04-09 12:17:42 -05:00
3 changed files with 36 additions and 6 deletions

View file

@ -2,6 +2,30 @@
Command-line tool to encode and decode arbitrary protobuf data.
## Installation
This program requires Crystal. See: https://crystal-lang.org/install/
### 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
version: ~> 0.1.5
```
## Usage
```
@ -57,9 +81,13 @@ $ echo 'CkEKCeOCj+OBn+OBlxDSCSIQWmQ730+N8z8tsp3vp8YJQCoSCAESBzA4MDAwMDAaBQ26sSZE
}
```
## 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.
## Contributing
1. Fork it (<https://github.com/omarroth/protodec/fork>)
1. Fork it (<https://github.com/iv-org/protodec/fork>)
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`)

View file

@ -1,13 +1,14 @@
name: protodec
version: 0.1.2
version: 0.1.5
authors:
- Omar Roth <omarroth@protonmail.com>
- Invidous team
targets:
protodec:
main: src/protodec.cr
crystal: 0.31.1
crystal: ">= 0.34.0, < 2.0.0"
license: GPLv3

View file

@ -213,6 +213,9 @@ module Protodec
when "bytes"
VarLong.to_io(io, value.size.to_i64)
value.as_a.each { |byte| io.write_byte byte.as_i.to_u8 }
else # "string"
VarLong.to_io(io, value.to_s.bytesize.to_i64)
io.print value.to_s
end
end
else
@ -465,9 +468,7 @@ module Protodec
Any.new(raw.clone)
end
def self.cast_json(object)
raise "Invalid type" if !object.is_a?(Hash)
def self.cast_json(object : Hash)
JSON::Any.new(object.transform_values do |value|
case value
when .is_a?(Hash)