RFE: HCL Support
Hashicorp developed HCL as an alternative to JSON and YAML and allows its use with some of their tools. As some of our tools use anymarkup and interact with some Hashicorp tools, I would like anymarkup to support HCL.
You know, I started thinking about this just 2 days ago :)
There are two key points here:
- https://github.com/virtuald/pyhcl package is the only Python HCL manipulation library I could find and it only supports parsing, but not dumping HCL. I'll first need to work with pyhcl upstream to implement dumping.
- I'm a bit worried that not everyone using anymarkup wants HCL. In fact, I think most people only use 2-3 backends, but have to install all dependencies. I'm starting to think that I should introduce package
anymarkup-core, that would have all the current code, but would import the individual parsers dynamically. This would allow people to install and use justanymarkup-corewith a limited set of parsers of their choice.anymarkupwould be just a metapackage, that would installanymarkup-coreand all parsers, so people could still just install that and get going. Does that sound ok?
Note that implementing the HCL support may get a bit tricky, as HCL seems to be ambiguous and that needs to be sorted out in the first place [1]. The pyhcl implementation of dumping pretty much depends on that, so I'll wait until [1] is resolved and then go on with implementing this.
(I sorted out the second point by creating https://github.com/bkabrda/anymarkup-core and making anymarkup be pretty much only "meta-package" to install all the dependencies + anymarkup-core itself. I released that work in 0.5.0 and would welcome testing/comments.)
[1] https://github.com/hashicorp/hcl/pull/24
Probably need a new issue for this, but TBH, I think you should include all the markups by default to make for a better first time user experience. I can't imagine it is all that much disk or time to install them all. However, once someone wants to move to production (or whatever) or becomes a "power user" the ability to remove markups they don't use would be nice. However, as I re-read your remark, maybe that is what you said? :)
So here's what I did:
- created anymarkup-core, that has all the code, but try/except imports, doesn't explicitly depend on any of the parsers
- made anymarkup a "meta-package", which basically only installs all the parsers + anymarkup-core; and it also imports all the toplevel functions + exceptions from anymarkup-core
Effectively, there is no visible change for people who just install "anymarkup" - and that is still the preferred way. The only change is that you can choose to install anymarkup-core with only a limited set of parsers, if you really need to do that for a reason.
Github needs a "like" button. +1
You can always tweet about how awesome I am (and I have twitter account now - https://twitter.com/slavek_k - , so that makes as cool as anyone else!)
I may have to wait for the HCL support ;)