Sha256: 87d13a6603e67a24dacdc02f671dfb05b5ade3cdbc6f72a51ee3f52ab6f5ae40

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'optparse'

module BulldozeRenamer
  class Shell
    BANNER = <<"EOT"
usage: #{$0} path CurrentNameInCamelCase TargetName

Will do a crude renaming of everything in the current directory. It
uses `git ls-files` to find the files so only things checked into
git are subject to change.

This script is still potentially dangerous, use with caution.

By default only an overview is shown of what changes will be made
in what files. To actually perform those changes, pass the '-p'
option.
EOT

    def self.usage(err: STDERR)
      err.puts BANNER
      exit 1
    end

    def self.start(argv, out: STDOUT, err: STDERR)
      options = {
        current_name: nil,
        target_name: nil,
        perform: false
      }

      OptionParser.new do |parser|
        parser.banner = BANNER

        parser.on("-p", "--perform", "Perform the substitutions on the files") do |perform|
          options[:perform] = perform
        end
      end.parse! argv

      unless argv.size == 3
        self.usage(err: err)
      end

      options[:path] = argv[0]
      options[:current_name] = argv[1]
      options[:target_name] = argv[2]

      RenamingOrchestrator.rename_with_options(options, out: out, err: err)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bulldoze_renamer-0.0.4 lib/bulldoze_renamer/shell.rb
bulldoze_renamer-0.0.3 lib/bulldoze_renamer/shell.rb
bulldoze_renamer-0.0.2 lib/bulldoze_renamer/shell.rb
bulldoze_renamer-0.0.1 lib/bulldoze_renamer/shell.rb