mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.1k stars 336 forks source link

cmd/shfmt: implement --from-json and improve -tojson #900

Closed mvdan closed 2 years ago

mvdan commented 2 years ago

(see commit message)

Fixes #35 again, as we never implemented the "read JSON" side.

mvdan commented 2 years ago

cc @cilki @JounQin

mvdan commented 2 years ago

A large portion of the diff is JSON output in test files, which was automatically generated via go test -u. It shouldn't be closely reviewed, but I did skim it for any mistakes or unexpected changes.

JounQin commented 2 years ago

So it won't a core API but left in shfmt right? I'd like to use it without shfmt for small bundle, should I copy/paste related codes instead?

mvdan commented 2 years ago

@JounQin One step at a time :) If I was implementing from-json, removing reflect, and adding the library API all in one PR, this would take weeks and be an absolutely massive change.

JounQin commented 2 years ago

@mvdan Thanks for clarifying, I just want to make sure it will be in core API in the future.

mvdan commented 2 years ago

Did one last push as I forgot to update the man page; see https://github.com/mvdan/sh/compare/46e0c4e09353c070bc3e23b1aac4a3b800c64d4b..e5d80446cfdede8b096dd7c9553edf1e73ce5ab7. I'll be merging on green. Thanks for the review!