Sha256: e7276e018a068ff9a56afa14ab14dee5aca6e759df1ec0e1732e0faf3b7534f0

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'mvmv'

options = {}
usage = "
usage:    mvmv [OPTIONS] <command> [<args>] <files>

commands:
          mvmv prefix       <prefix>     <files>
          mvmv suffix       <suffix>     <files>
          mvmv name         <name>       <files>
          mvmv name-suffix  <suffix>     <files>
          mvmv ext          <.extension> <files>
          mvmv upper                     <files>
          mvmv lower                     <files>

          mvmv regexp       <from> <to>  <files>
          mvmv regexpi      <from> <to>  <files>
          mvmv name-regexp  <from> <to>  <files>
          mvmv name-regexpi <from> <to>  <files>

options:
          -f, --force       Force rename
              --no-color    Disable ANSI color codes
".strip

options = {}
while ARGV.first =~ /^-/
  case ARGV.shift
  when '-f', '--force'
    options[:force] = true
  when '--no-color'
    options[:color] = false
  end
end

if ARGV.length < 2
  puts usage
  exit 1
end

command = ARGV[0].to_s.gsub('-', '_').to_sym
args    = ARGV[1..-1]
mvmv    = Mvmv.new options.fetch(:color, true)
begin
  if options[:force]
    mvmv.rename! command, *args
  else
    mvmv.rename command, *args
  end
rescue ArgumentError => e
  puts opts
  exit 1
rescue Exception => e
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mvmv-0.1.0 bin/mvmv