Friday, 13 March 2015

Thor, building powerful command-line interfaces.

require "thor"
class MyCLI < Thor
desc "hello NAME", "say hello to NAME"
option :from
def hello(name)
puts "from: #{options[:from]}" if options[:from]
puts "Hello #{name}"
end
end
MyCLI.start(ARGV)
# ruby ./cli.rb hello kotopoulo
# ruby ./cli hello Yehuda --from "Carl Lerche"
view raw gistfile1.rb hosted with ❤ by GitHub

No comments:

Post a Comment