Skip to content

Instantly share code, notes, and snippets.

@hoolymama
Created February 18, 2012 17:06
Show Gist options
  • Save hoolymama/1860206 to your computer and use it in GitHub Desktop.
Save hoolymama/1860206 to your computer and use it in GitHub Desktop.
commandline thor generators with invocations
module Flak
class CLI < Thor
register(Generate, 'generate', 'generate <something>', 'Generate a new something.')
end
end
#!/usr/bin/env ruby
require 'flak'
# start CLI as a shell command
Flak::CLI.start
module Flak
class Generate < Thor
desc "project [name]", "Prints the project making step"
def project(name)
puts "making first project file #{name}"
invoke :config
invoke :project_sub
end
desc "config [name]", "Prints the config making step"
def config(name)
puts "making first config file #{name}"
invoke :project_sub
end
desc "project_sub [name]", "Prints the project_sub making step"
def project_sub(name)
puts "making subsystem file #{name}"
end
def self.banner(task, namespace = false, subcommand = true)
task.formatted_usage(self, true, subcommand).split(':').join(' ')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment