#!/usr/bin/env ruby require 'rubygems' require 'mvmv' options = {} usage = " usage: mvmv [OPTIONS] [] commands: mvmv prefix mvmv suffix mvmv name mvmv name-suffix mvmv ext <.extension> mvmv upper mvmv lower mvmv regexp mvmv regexpi mvmv name-regexp mvmv name-regexpi 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