Replies: 3 comments
-
Thank you for your issue! Tokei can't emit binary data to the terminal, so the output is hex encoded, so you first need to decode the binary from hexadecimal if you're using the CLI. You can get the raw bytes directly by using tokei as a library. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. How would I go about converting the hex output to real binary?
Is this literally can't or rather doesn't? Seems like the least surprising thing would be to get real binary CBOR format output, similar to what the official CBOR tools produce. |
Beta Was this translation helpful? Give feedback.
-
Printing raw binary data to the terminal is not safe. The terminal has a lot of control codes to control the layout, position, and other properties, and outputting binary would unintentionally cause these control codes to be printed to the screen, (since the binary of the file might match the binary of the control code) and at best you get a bunch of confusing output, or having your terminal layout messed up, and at worst a malicious actor could craft binary output that causes your machine to run code. Neither one of those things is a good experience for users, so tokei does not output binary to terminal.
Well I don't what system you're on, but on macOS and Linux there should be a tool called
|
Beta Was this translation helpful? Give feedback.
-
Since I'm new to CBOR I'm open for me being at fault here but I've not been able to parse the output from
--output cbor
with any tool thus far. Will use output from one of my open source repos as example:Regular
tokei
output:With
--output json
:With
--output cbor
:First impression of that output is that it doesn't look like binary output at all. If I try to read it via cbor-ruby I get
CBOR::MalformedFormatError (extra bytes follow after a deserialized object)
. If I try to read it via the official diagnostics toolcbor-diag
eg. by runningtokei --output cbor | cbor2json.rb
I again get a similar errorextra bytes follow after a deserialized object of 2 bytes (RuntimeError)
. If I try generated CBOR via diagnostic tool from JSON viatokei --output json | json2cbor.rb
I get:This looks like binary output and appears to be correct since I can pipe it back into the diagnostic tool and re-produce the JSON, eg.
tokei --output json | json2cbor.rb | cbor2json.rb
.So my conclusion would be that
--output cbor
doesn't actually output in CBOR format.Environment: MacOS Big Sur running the latest
tokei
installed viabrew install tokei
.Beta Was this translation helpful? Give feedback.
All reactions