Sha256: f239a8c8fe08ec91370d67ca7f7b9f1890ace0b6b4d60acc1595c2cc3ed1cb6c

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

#!/usr/bin/env ruby

require 'rbbt-util'
require 'rbbt/util/simpleopt'
require 'rbbt/resource'
require 'rbbt/workflow'
require 'rbbt/util/ssh'

$0 = "rbbt #{$previous_commands*" "} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF

Find files

$ #{$0} [<options>] (<resource> <path>|<path>)

-h--help Print this help
-r--requires* Files to require; 'all' for all in Rbbt.etc.requires
-lw--load_workflow* Files to require; 'all' for all in Rbbt.etc.requires
-w--where* Where to look for the path

EOF
if options[:help]
  if defined? rbbt_usage
    rbbt_usage 
  else
    puts SOPT.doc
  end
  exit 0
end

resource, path = ARGV
path, resource = resource, nil

raise MissingParameterException.new(:path) if path.nil?

case options[:workflows]
when nil, false, "false", "none"
when "all"
  Rbbt.etc.workflows.list.each do |workflow|
    Workflow.require_workflow file
  end if Rbbt.etc.workflows.exists?
else
  options[:workflows].split(/[ ,;|]/).each do |workflow|
    Workflow.require_workflow workflow
  end
end

case options[:requires]
when nil, false, "false", "none"
when "all"
  Rbbt.etc.requires.list.each do |file|
    require file
  end if Rbbt.etc.requires.exists?
else
  options[:requires].split(/[ ,;|]/).each do |file|
    require file
  end
end

location = nil
where = options[:where]
all = options[:all]

begin
  resource = Workflow.require_workflow resource
rescue
  begin
    resource = Kernel.const_get(resource)
  rescue
    raise "Resource not found: #{ resource }"
  end
end if resource

path = (resource || Rbbt)[path]

if where.nil? || where == 'all' || path.search_paths.include?(where.to_sym)
  location = path.find(where)

  if Array === location
    puts location * "\n"
  else
    puts location
  end
else
  puts RbbtSSH.command(where, $0, ARGV, options.merge("where" => :all)).read
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbbt-util-5.37.16 share/rbbt_commands/resource/find