Module: Bones::App::Command::ClassMethods

Defined in:
lib/bones/app/command.rb

Instance Method Summary collapse

Instance Method Details

#description(*args) ⇒ Object


174
175
176
177
# File 'lib/bones/app/command.rb', line 174

def description( *args )
  @description = args.join("\n") unless args.empty?
  @description
end

#option(*args, &block) ⇒ Object


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/bones/app/command.rb', line 184

def option( *args, &block )
  args.flatten!
  block = args.pop if block.nil? and Proc === args.last

  if block
    args.each { |val|
      next unless val.instance_of? String
      next unless val =~ %r/^--(\w+)/

      args << "__#$1"
      define_method(args.last.to_sym, &block)
      options << args
      break
    }
  else
    options << (args.length > 1 ? args : args.first )
  end
end

#optionsObject


203
204
205
# File 'lib/bones/app/command.rb', line 203

def options
  @options ||= []
end

#summary(*args) ⇒ Object


179
180
181
182
# File 'lib/bones/app/command.rb', line 179

def summary( *args )
  @summary = args.join("\n") unless args.empty?
  @summary
end

#synopsis(*args) ⇒ Object


169
170
171
172
# File 'lib/bones/app/command.rb', line 169

def synopsis( *args )
  @synopsis = args.join("\n") unless args.empty?
  @synopsis
end