Cosmo/HackMan

Any ideas how to make custom generators work?

Opened this issue · 1 comments

Cosmo commented

I haven't figured out, how to make HackMan work with custom generators.

My initial idea was to create a directory inside of ~/.hackman/CustomGenerators where user created generators can live.
I was assuming, that creating a symbolic link from ~/.hackman/Generators to HackMan/Sources/HackManLib/ will solve everything.
It turns out, that Xcode shows the files and directories of the linked directory.
But they won't be part of the (compiled) project. So no autocompletion and most importantly, no integration into the build.

Another idea would be to add a file that lists all paths where generators live. For instance by calling it ~/.hackmanPaths. In each line of that file represents a path of generators.
In addition to that, we would have a build script, that looks for the .hackmanPaths file and copies all the generators of the directories listed there, into a HackMan/Sources/HackManLib/CustomGenerators directory and compiles hackman.
But that way, you have only loose files that have no knowledge of the HackMan code. That means: Also no autocompletion.

I'm not quite following how autocompletion works here... do you mean autocompletion of hackman commands on the command line? Or do you mean in source files somehow?

Two opinions:

  1. I think it would be better to make a ~/.hackman_config rather than a file specifically for custom generator paths. This could just contain an array of custom generator paths as the first of future configuration options. (I could also imagine wanting to configure other things like whether to run git commands automatically in there.)

  2. I also think it would be better not to have to copy the generators at all, if it can be helped. It will be limiting, but you could probably get away with not having code for each generator at all, and just including the .stf files in the generator paths.

This would mean that custom generators are a special type, and do not have their own class the way most of the other generators do. Instead, there would be a single generic generator class that is used if none of the other generators match. That class would check the custom generator paths for the specified Generator type's swift template.

Let me know if that doesn't make sense.