#!/usr/bin/env ruby require 'commander/import' require 'kryo' program :name, 'kryo' program :version, Kryo::VERSION program :description, 'Kryo is a static blog generator' default_command :help command :new do |c| c.syntax = 'kryo new ' c.description = 'Builds a new kryo application' c.action do |args, options| raise ArgumentError.new("'name' is required") if args.empty? name = args[0] Kryo::Generators::SiteGenerator.invoke(name) end end command :generate do |c| c.syntax = "kryo generate [options]" c.description = "Generates something" c.action do |args, options| raise ArgumentError.new("you need to specify a generator") if args.empty? case args[0] when 'post' raise ArgumentError.new("you need to specify a title for the post") if args.count < 2 title = args[1..-1].join(' ') Kryo::Generators::PostGenerator.invoke(title) else raise ArgumentError.new("#{args[0]} generator doesn't exist") end end end alias_command :g, :generate