Sha256: 6573b4f42d0a9456f7afc6a0cac0b08f437c4e99e0e12393068ffbc3a551370d

Contents?: true

Size: 1.27 KB

Versions: 2

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 usage
  exit 1
rescue Exception => e
  exit 1
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mvmv-0.1.2 bin/mvmv
mvmv-0.1.1 bin/mvmv