Sha256: d81cccf5ee73d2d63256d056acaaca8d11cdbf2152240ac246ae7934f83e6a34
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
#!/usr/bin/env ruby require 'utils' include Utils require 'spruz/go' include Spruz::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 -h display this help EOT exit 1 end args = go 'I:a:rdDcieh' 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 finder = Finder.new( :pattern => pattern, :args => args, :roots => roots ).search do |output| puts output end if args['e'] edit_files finder.pathes end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
utils-0.0.18 | bin/discover |
utils-0.0.17 | bin/discover |
utils-0.0.16 | bin/discover |
utils-0.0.15 | bin/discover |
utils-0.0.14 | bin/discover |