Sha256: 643b74a18483cab43271bc00bc79fcb54b1d445c16ebed48544e75d4d1d640be

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby
require 'thor'

lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)

require 'propre'
require 'propre/version'

class CLI < Thor
  include Propre
  desc 'lint [FILENAME...]', 'Sanitize the specified file. Use --dry for dry run'
  option :dry,    type: :boolean
  option :color,  type: :boolean, default: true
  def lint(*args)
    String.disable_colorization(true) unless options[:color]
    args.each do |oldpath|
      basename, newname, metadata = Propre.basename_newname_metadata(oldpath)
      working_directory = File.dirname(oldpath)
      newpath = "#{File.join(working_directory, newname + File.extname(oldpath))}"
      if options[:dry]
        unchanged = basename == newname ? :green : :yellow
        puts "#{oldpath} -> #{newpath}".colorize(unchanged)
      else
        File.rename(oldpath, "#{newpath}")
      end
    end
  end
  default_task :lint

  desc 'metadata [FILENAME]', 'Show metadata about the specified movie or episode'
  option :format, default: 'json'
  def metadata(filename)
    basename, newname, metadata = Propre.basename_newname_metadata(filename)
    metadata[:title] = newname
    puts metadata.to_json
  end

  map %w(--version -v) => :__version
  desc '--version, -v', 'Show version information about this program and quit.'
  def __version
    puts "#{Propre} - v#{Version::VERSION}"
  end
end

CLI.start(ARGV)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
propre-0.3.4 bin/propre
propre-0.3.3 bin/propre
propre-0.3.2 bin/propre