Sha256: cb5a863e1de7fbf85b6ba3fa2fc96da6be64285b3bbbc046566117d88c0e20d1

Contents?: true

Size: 1.49 KB

Versions: 24

Compression:

Stored size: 1.49 KB

Contents

#!/usr/bin/env ruby

require 'utils'
include Utils
require 'tins/go'
include Tins::GO

def edit_files(pathes)
  editor = Utils::Editor.new do |config|
    config.wait = true
  end
  editor.edit(*pathes)
end

def usage
  puts <<-EOT
Usage: #{File.basename($0)} [OPTS] PATTERN [PATHES]

PATTERN is a pattern expression which is find the files. PATHES are the
directory and file pathes that are searched.

Options are

  -r          interpret PATTERN argument as regex not fuzzy
  -d          discover directories as well
  -D          discover only directories
  -c          disable color output
  -i          use case insensitive matches
  -e          open the matching files with edit command
  -a CSET     use only character set CSET from PATTERN
  -I SUFFIX   only include files with suffix SUFFIX during finding
  -b          match also binary files
  -h          display this help

Version is #{File.basename($0)} #{Utils::VERSION}.
  EOT
  exit 1
end

args = go 'I:a:rdDciebh'
args['h'] and usage
pattern = ARGV.shift or usage
roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }

Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args['c']
STDOUT.sync = true
config = Utils::Config::ConfigFile.new
config.parse_config_file File.expand_path('~/.utilsrc')
args['b'] ||= config.discover.binary
finder = Finder.new(
  :pattern => pattern,
  :args    => args,
  :roots   => roots,
  :config  => config
).search do |output|
  puts output
end
if args['e']
  edit_files finder.pathes
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
utils-0.0.48 bin/discover
utils-0.0.47 bin/discover
utils-0.0.46 bin/discover
utils-0.0.45 bin/discover
utils-0.0.44 bin/discover
utils-0.0.43 bin/discover
utils-0.0.42 bin/discover
utils-0.0.41 bin/discover
utils-0.0.40 bin/discover
utils-0.0.39 bin/discover
utils-0.0.38 bin/discover
utils-0.0.37 bin/discover
utils-0.0.36 bin/discover
utils-0.0.35 bin/discover
utils-0.0.34 bin/discover
utils-0.0.33 bin/discover
utils-0.0.32 bin/discover
utils-0.0.31 bin/discover
utils-0.0.30 bin/discover
utils-0.0.29 bin/discover