Class: Basketcase::Command

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Utils
Defined in:
lib/basketcase.rb

Overview

Base ClearCase command

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#mkpath

Constructor Details

#initialize(basketcase) ⇒ Command

Returns a new instance of Command.



177
178
179
180
181
182
# File 'lib/basketcase.rb', line 177

def initialize(basketcase)
  @basketcase = basketcase
  @listener = DefaultListener
  @recursive = false
  @graphical = false
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



209
210
211
# File 'lib/basketcase.rb', line 209

def comment
  @comment
end

#listener=(value) ⇒ Object (writeonly)

Sets the attribute listener

Parameters:

  • value

    the value to set the attribute listener to.



184
185
186
# File 'lib/basketcase.rb', line 184

def listener=(value)
  @listener = value
end

#targets=(value) ⇒ Object (writeonly)

Sets the attribute targets

Parameters:

  • value

    the value to set the attribute targets to.



185
186
187
# File 'lib/basketcase.rb', line 185

def targets=(value)
  @targets = value
end

Instance Method Details

#accept_args(args) ⇒ Object

Handle command-line arguments:

  • For option arguments of the form “-X”, call the corresponding option_X() method.

  • Remaining arguments are stored in @targets



215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/basketcase.rb', line 215

def accept_args(args)
  while /^-+(.+)/ === args[0]
    option = args.shift
    option_method_name = "option_#{$1}"
    unless respond_to?(option_method_name)
      raise UsageException, "Unrecognised option: #{option}"
    end
    option_method = method(option_method_name)
    option_method.call(*args.shift(option_method.arity))
  end
  @targets = args
  self
end

#effective_targetsObject



229
230
231
# File 'lib/basketcase.rb', line 229

def effective_targets
  TargetList.new(@targets.empty? ? ['.'] : @targets)
end

#helpObject



173
174
175
# File 'lib/basketcase.rb', line 173

def help
  "Sorry, no help provided ..."
end

#option_comment(comment) ⇒ Object Also known as: option_m



203
204
205
# File 'lib/basketcase.rb', line 203

def option_comment(comment)
  @comment = comment
end

#option_graphicalObject Also known as: option_g



197
198
199
# File 'lib/basketcase.rb', line 197

def option_graphical
  @graphical = true
end

#option_recurseObject Also known as: option_r



191
192
193
# File 'lib/basketcase.rb', line 191

def option_recurse
  @recursive = true
end

#report(status, path, version = nil) ⇒ Object



187
188
189
# File 'lib/basketcase.rb', line 187

def report(status, path, version = nil)
  @listener.call(ElementStatus.new(path, status, version))
end

#specified_targetsObject

Raises:



233
234
235
236
# File 'lib/basketcase.rb', line 233

def specified_targets
  raise UsageException, "No target specified" if @targets.empty?
  TargetList.new(@targets)
end

#synopsisObject



169
170
171
# File 'lib/basketcase.rb', line 169

def synopsis
  ""
end