Skip to content

Instantly share code, notes, and snippets.

@dunedain289
Created July 16, 2012 18:47
Show Gist options
  • Save dunedain289/3124276 to your computer and use it in GitHub Desktop.
Save dunedain289/3124276 to your computer and use it in GitHub Desktop.
Thor layout for NewReg
require "cli.rb"
CLI::Base.start
require 'thor'
module CLI
class Two < Thor
desc "twotwo", "output twotwo"
def twotwo
puts "twotwo"
end
end
class Three < Thor
desc "threethree", "output threethree"
def threethree
puts '33'
end
end
class Base < Thor
desc "two SUBCOMMAND ...ARGS", "manage stuff for two"
subcommand "two", Two
desc "three SUBCOMMAND ...ARGS", "manage stuff for three"
subcommand "three", Three
end
end
@dunedain289
Copy link
Author

app two twotwo -- runs CLI::Two#twotwo
app three threethree -- runs CLI::Three#threethree
app -- prints top-level help, just listing subcommands
app two -- prints help for CLI::Two, listing twotwo only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment