hyde / hyde-old

Static website generator inspired by Jekyll
http://ringce.com/hyde
MIT License
876 stars 82 forks source link

Feature Request: Git-style CLI + plugin interface #10

Open wandernauta opened 14 years ago

wandernauta commented 14 years ago

I'd like Hyde to take Git/webgen style commands as well, e.g. hyde.py init and hyde.py serve.

This could also be a beginning of a plugin system - hyde.py foo could try to run a script called foo.py in a plugins directory inside the main Hyde directory.

navilan commented 14 years ago

I'd like that feature as well. Sucks typing -i, -g etc. Maybe creating a default fab file would be the quickest way to solve this. http://stevelosh.com/blog/2010/01/moving-from-django-to-hyde/

wandernauta commented 14 years ago

Using fabfiles would add an additional dependency on Fabric (which in turn depends on PyCrypto and so on). I'm afraid it might be considered overkill. Changing

if len(args):
    parser.error("Unexpected arguments encountered.")

to

if len(args):
    if (args[0] == 'serve'):
        options.webserve = True
    else:
        findplugin(args[0]).run(args)
    # ...

might do the trick as well, right?

navilan commented 14 years ago

Agreed.

wandernauta commented 14 years ago

Would the following work?

if len(args):
    if (args[0] in ('generate', 'g', 'gen')):
        options.generate = True
    elif (args[0] in ('serve', 'w', 'srv')):
        options.webserve = True
    elif (args[0] in ('init', 'create', 'i')): # 'Create' seems to be what Webgen calls it
        options.init = True
    elif (os.path.isfile(PROG_ROOT + os.sep + "plugins" + os.sep + args[0] + ".py")):
        # Plugin-running code here
        pass
    else:
        parser.error("Unexpected arguments encountered.")
navilan commented 14 years ago

Since every option to hyde is a subcommand, I would rather have something like:

command = load_command(args[0]) if not command: # handle bad command command.execute(args[1:])

Using something like http://code.google.com/p/argparse/ might also make this simpler.

wandernauta commented 14 years ago

Great idea :D