Class: Basketcase::LsCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/basketcase.rb

Instance Attribute Summary

Attributes inherited from Command

#comment, #listener, #targets

Instance Method Summary collapse

Methods inherited from Command

#accept_args, #effective_targets, #initialize, #option_comment, #option_graphical, #option_recurse, #report, #specified_targets

Methods included from Utils

#mkpath

Constructor Details

This class inherits a constructor from Basketcase::Command

Instance Method Details

#executeObject



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/basketcase.rb', line 334

def execute
  args = ''
  args += ' -recurse' if @recursive
  args += ' -directory' if @directory_only
  cleartool("ls #{args} #{effective_targets}") do |line|
    case line
    when /^(.+)@@(\S+) \[hijacked/
      report(:HIJACK, mkpath($1), $2)
    when /^(.+)@@(\S+) \[loaded but missing\]/
      report(:MISSING, mkpath($1), $2)
    when /^(.+)@@\S+\\CHECKEDOUT(?: from (\S+))?/
      element_path = mkpath($1)
      status = element_path.exist? ? :CO : :MISSING
      report(status, element_path, $2 || 'new')
    when /^(.+)@@(\S+) +Rule: /
      next unless @include_all
      report(:OK, mkpath($1), $2)
    when /^(.+)/
      path = mkpath($1)
      if ignored?(path)
        log_debug "ignoring #{path}"
        next
      end
      report(:LOCAL, path)
    else
      cannot_deal_with line
    end
  end
end

#helpObject



310
311
312
313
314
315
316
317
318
319
320
# File 'lib/basketcase.rb', line 310

def help
  <<EOF
List element status.

-a(ll)      Show all files.
        (by default, up-to-date files are not reported)

-r(ecurse)  Recursively list sub-directories.
        (by default, just lists current directory)
EOF
end

#option_allObject Also known as: option_a



322
323
324
# File 'lib/basketcase.rb', line 322

def option_all
  @include_all = true
end

#option_directoryObject Also known as: option_d



328
329
330
# File 'lib/basketcase.rb', line 328

def option_directory
  @directory_only = true
end

#synopsisObject



306
307
308
# File 'lib/basketcase.rb', line 306

def synopsis
  "[<element> ...]"
end