Class: Basketcase::Command
- Inherits:
-
Object
- Object
- Basketcase::Command
- Extended by:
- Forwardable
- Includes:
- Utils
- Defined in:
- lib/basketcase.rb
Overview
Base ClearCase command
Direct Known Subclasses
AutoCommand, CheckinCommand, CheckoutCommand, DiffCommand, DirectoryModificationCommand, HelpCommand, LogCommand, LsCoCommand, LsCommand, UncheckoutCommand, UpdateCommand, VersionTreeCommand
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#listener ⇒ Object
writeonly
Sets the attribute listener.
-
#targets ⇒ Object
writeonly
Sets the attribute targets.
Instance Method Summary collapse
-
#accept_args(args) ⇒ Object
Handle command-line arguments: - For option arguments of the form “-X”, call the corresponding option_X() method.
- #effective_targets ⇒ Object
- #help ⇒ Object
-
#initialize(basketcase) ⇒ Command
constructor
A new instance of Command.
- #option_comment(comment) ⇒ Object (also: #option_m)
- #option_graphical ⇒ Object (also: #option_g)
- #option_recurse ⇒ Object (also: #option_r)
- #report(status, path, version = nil) ⇒ Object
- #specified_targets ⇒ Object
- #synopsis ⇒ Object
Methods included from Utils
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
#comment ⇒ Object
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
184 185 186 |
# File 'lib/basketcase.rb', line 184 def listener=(value) @listener = value end |
#targets=(value) ⇒ Object (writeonly)
Sets the attribute targets
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_targets ⇒ Object
229 230 231 |
# File 'lib/basketcase.rb', line 229 def effective_targets TargetList.new(@targets.empty? ? ['.'] : @targets) end |
#help ⇒ Object
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_graphical ⇒ Object Also known as: option_g
197 198 199 |
# File 'lib/basketcase.rb', line 197 def option_graphical @graphical = true end |
#option_recurse ⇒ Object 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_targets ⇒ Object
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 |
#synopsis ⇒ Object
169 170 171 |
# File 'lib/basketcase.rb', line 169 def synopsis "" end |