class Looks::Command::Base
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/looks/command/base.rb, line 12 def initialize(config) @opts = OptionParser.new @config = config configure(@opts) set_banner set_version end
Public Instance Methods
run(args)
click to toggle source
# File lib/looks/command/base.rb, line 21 def run(args) begin @opts.parse! args rescue OptionParser::ParseError => e raise Error, e end usage unless args.length == arguments.length execute(args) end
to_s()
click to toggle source
# File lib/looks/command/base.rb, line 37 def to_s "#{@opts.help}\n" end
usage()
click to toggle source
# File lib/looks/command/base.rb, line 33 def usage abort to_s end
Protected Instance Methods
arguments()
click to toggle source
# File lib/looks/command/base.rb, line 43 def arguments [] end
configure(opts)
click to toggle source
# File lib/looks/command/base.rb, line 47 def configure(opts) opts.separator "" opts.separator "Options:" opts.on_tail('-h', '--help', 'Show this help') do |help| puts to_s exit end end
execute(args)
click to toggle source
# File lib/looks/command/base.rb, line 57 def execute(args) end
Private Instance Methods
name()
click to toggle source
# File lib/looks/command/base.rb, line 62 def name self.class.name.split('::').last.downcase end
set_version()
click to toggle source
# File lib/looks/command/base.rb, line 78 def set_version @opts.version = Looks::VERSION end