rvagg / cborg

fast CBOR with a focus on strictness
Other
47 stars 13 forks source link

Ability to configure width for cli diagnostic output #116

Closed c2bo closed 6 months ago

c2bo commented 7 months ago

The cli does not offer any possibility to adjust the width of the diagnostic output and always defaults to 100. The library offers that as an argument: https://github.com/rvagg/cborg/blob/7d9f0c36a8588218418e1847ee6bc1d91ba184b9/lib/diagnostic.js#L12

I looked at the arg parsing and I am not sure if it is a good idea to put a width argument in there, but I do believe adding a check for an optional environment variable would be a pretty easy & pragmatic solution. I can propose a small PR if feedback is positive.

rvagg commented 7 months ago

Yep, nice idea, I'd be happy to see a PR for that. Have a look at bin.js and the --pretty argument for the json output: https://github.com/rvagg/cborg/blob/7d9f0c36a8588218418e1847ee6bc1d91ba184b9/lib/bin.js#L57, you could just copy that pattern for a --width or --cols.

At some point a proper args parser would be a good idea, but I think that can be deferred for a bit longer.

c2bo commented 7 months ago

I looked at that but we would need to parse 2 args (--width and a value) and that felt a bit hacky when I thought how that would look like. I am open to explore that option and try to add it as an arg instead of environment variable.

github-actions[bot] commented 6 months ago

:tada: This issue has been resolved in version 4.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: