grego / blades-plugins

A currated list of Blades plugins
0 stars 0 forks source link

How to pass options to plugin? #1

Closed Heiss closed 2 years ago

Heiss commented 2 years ago

Hey,

i love the concept of blades, because hugo (my current goto static generator) lacks plugin system and does not play very well with other programming languages. I love the piping possibilities of blades. So i implement a kroki plugin (which was not possible with hugo as far as i know) on my own. But this uses the default servers currently, which is not acceptable in my working environment (we try to host all services on our own). So it would be very beneficial, if you can specify the kroki server to use via the cli.

Something like this comes to my mind:

cat pages.json | blades-kroki --kroki-server https://kroki.my-institution.org

Can we implement something like this within the blades plugin system?

I think some grouping in toml would be practiable:

[plugins]
transform = ["blades-kroki"]

[plugins.blades-kroki]
kroki-server = "https://kroki.my-institution.org"

So blades looks up for all given transform plugins ["blades-kroki"], if there is any options given in the toml. Then it takes all keynames kroki-server and values https://kroki.my-institution.org and print it at the end of the given command blades-kroki.

What do you think about it? This would make the plugin system more usable in favor of reuse already existing software like coreutils etc.

grego commented 2 years ago

This should already be possible:

[plugins]
transform = ["blades-kroki --kroki-server https://kroki.my-institution.org"]
Heiss commented 2 years ago

Ah okay. That makes it very easy with clap to enable such options. I implemented it right here. Thanks for this information.