Sourcery icon indicating copy to clipboard operation
Sourcery copied to clipboard

Add option to store output in a file (json)

Open ilyapuchka opened this issue 6 years ago • 3 comments

Sourcekitten has the option to store structure output in the file so that it can be then used by other tools. We can do the same to enable other tools to act on types metadata. @krzysztofzablocki @Antondomashnev thoughts?

ilyapuchka avatar Aug 17 '18 20:08 ilyapuchka

fine with me, we already have the data and could just as well generate the boilerplate for json generation

krzysztofzablocki avatar Aug 19 '18 06:08 krzysztofzablocki

Sorry for the late reply. If that isn't much of a work + could be useful for other tools (do we have any request for it btw?) I think it's a good enhancement.

Antondomashnev avatar Aug 22 '18 13:08 Antondomashnev

Hi guys, I just want to realise json output to std, i read contribution guide and found this topic 🙌

I have a POC here https://github.com/1is10/Sourcery/pull/1

is it what are you talking about or should I create another topic to discuss that one?

1is10 avatar Sep 16 '22 21:09 1is10

@1is10 what's your use-case for json output nowadays? we moved Sourcery to work as framework so one can build tools on top of Sourcery without using intermediate formats like json

krzysztofzablocki avatar Sep 20 '22 08:09 krzysztofzablocki

My first thoughts about json stdout was

  • dry run, it's useful for many cases for example to count autogenerated code lines, or by CI to check errors during code generation, without write on disk
  • post processing output without modifying templates in any script language
  • building tools in other languages, without linking sourcery framework directly

1is10 avatar Sep 21 '22 22:09 1is10

@1is10 ok, I'd be fine with adding feature like that if we can isolate the functionality not to add too much complexity to the tool

krzysztofzablocki avatar Sep 22 '22 08:09 krzysztofzablocki

i implemented it with --dry flag, and made a pull request here + ready to fix any issues related about isolation and overall logic, tested locally + added some tests for --dry option.

pull request link: https://github.com/krzysztofzablocki/Sourcery/pull/1097

1is10 avatar Sep 26 '22 11:09 1is10