Add cli options to output lookml - #89
Conversation
| json_string = json.dumps(result, indent=2) | ||
| print(json_string) | ||
|
|
||
| finally: |
There was a problem hiding this comment.
FileType objects dont work with context managers, this makes sure the file is closed even if they cannot be parsed.
517dd00 to
0006a83
Compare
joshtemple
left a comment
There was a problem hiding this comment.
Hey @remisalmon thank you for this PR and I'm sorry it's taken so long for me to review it. My only question is with the --write arg. Can you explain to me what you would use this for?
| group.add_argument( | ||
| "-w", | ||
| "--write", | ||
| action="store_true", | ||
| default=False, | ||
| help="parse and write back to file", | ||
| ) |
There was a problem hiding this comment.
What's the use case for parsing from a file and writing back to the same file?
There was a problem hiding this comment.
The lkml parser/dumper does a great job at cleaning up lkml files (separating measures from dimensions, correcting the indentation, etc.), the option to write it back to file would allow to use lkml as a auto-formatter in text editors, pre-commits, CI checks, etc. (like running black on .py files).
fafcb92 to
0976e5a
Compare
0976e5a to
f78206a
Compare
Hi @joshtemple I have removed that option, happy to add it back if you feel it belongs here. I replied just above in #89 (comment). I also added some cli tests to make sure the output (json or lookml) can be parsed back. |
This should close #88.