kr / hk

Fast Heroku client
https://hk.heroku.com/
77 stars 6 forks source link

remove version string from plugin info output format #68

Open kr opened 11 years ago

kr commented 11 years ago

Right now hk defines the HKPLUGINMODE=info format to include a version string:

name version: short help

long help

I included it because I thought it would be useful for hk to be able to interrogate the currently installed plugin about what version it is, to help with automatic updates. But the more we talk about auto updating plugins, the more I think hk ought to track the currently installed version itself. Hk will need to know which plugins it is responsible for auto-updating, which means storing a list of them somewhere. It's not much more work, then, to include the current version alongside the name in that list.

This makes it unnecessary for plugins to report their version. Having hk do a little more work means plugin authors have to do ever so slightly less. Since plugin authors will (hopefully) outnumber hk maintainers, this is a good thing. (And it narrows the interface between hk and the plugin a bit, also a good thing.)

So I think the format should be changed to:

name: short help

long help
bgentry commented 11 years ago

@kr thoughts on how to track installed versions of plugins? Just another file in ~/.hk ?

kr commented 11 years ago

Yes, I think a file ~/.hk/plugins. Json, ex:

[
  {"Name": "sudo", "Version": "20130102"}
]

Hk would add entries to this list when it installs an auto-updating plugin. Presumably there will be a command for that, like hk install sudo. It's fine for the user to install additional plugins not in this list, just by dropping them into the directory. Hk would only try to update plugins in the list.

bgentry commented 11 years ago

Do you have thoughts on putting more into a json manifest like this? I was thinking that plugins could have a json manifest that includes their help text or a command list of some sort. That would remove the need to shell out to plugins to get their version & help text.

Just thinking if you're going to track this stuff anyway, maybe there's an approach that goes all the way and removes the HKPLUGINMODE=info interface.

kr commented 11 years ago

We talked about this in person, I'll try to summarize here.

Plugins don't have to be installed or auto updated by hk. If you symlink a binary into /usr/local/hk/lib/plugin, it should still have functioning help text and usage. Since we need that interface anyway, all plugins should use it. But for those plugins that aren't auto updated by hk, they don't need a version string at all, as far as hk is concerned. Hk only uses the version string to know when a new version is available to auto update. So this seems to me like the right place to draw boundaries around the interfaces.

You also mentioned performance as a concern with exec'ing plugins, especially for the short help listing, since it has to execute all plugins. I haven't noticed that as a problem, but if it is bad, we have a couple of options to fix that, without necessarily having to change the interface. (Mainly I'm thinking of caching the help output.)