class Findr::CLI

Public Instance Methods

find_and_replace(pattern, replacement, path = '**/*') click to toggle source
# File lib/findr/cli.rb, line 9
def find_and_replace(pattern, replacement, path = '**/*')
  Findr.new(pattern, replacement, path, options).find_and_replace
end
help() click to toggle source

Show help by not using default feature of Thor, because this 'findr' command do not need arguments.

# File lib/findr/cli.rb, line 14
    def help
      print <<~EOT
      #{'findr'.bold} -- Find files in directory recursively and replace texts in the files.

      #{'Usage'.bold}
        findr pattern replacement [path]

      #{'Examples'.bold}
        # Replace 'apple' to 'lemon' in all files in current and children directory
        $ findr "apple" "lemon"

        # Delete a line with 'require' in all ruby file
        $ findr "require(.*?)\\n" "" "**/*.rb"

      #{'Details'.bold}
        -v, --verbose
            Verbose mode.
      EOT
    end