anymarkup icon indicating copy to clipboard operation
anymarkup copied to clipboard

RFE: HCL Support

Open langdon opened this issue 10 years ago • 7 comments

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.

langdon avatar Oct 15 '15 23:10 langdon

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 just anymarkup-core with a limited set of parsers of their choice. anymarkup would be just a metapackage, that would install anymarkup-core and all parsers, so people could still just install that and get going. Does that sound ok?

bkabrda avatar Oct 16 '15 06:10 bkabrda

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

bkabrda avatar Oct 19 '15 11:10 bkabrda

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? :)

langdon avatar Oct 20 '15 12:10 langdon

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.

bkabrda avatar Oct 20 '15 12:10 bkabrda

Github needs a "like" button. +1

langdon avatar Oct 22 '15 17:10 langdon

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!)

bkabrda avatar Oct 23 '15 08:10 bkabrda

I may have to wait for the HCL support ;)

langdon avatar Oct 23 '15 15:10 langdon