Sha256: 71f3298f1523ee2344a5f8b79511e2e77b96bcb4248279939f5506d12fb5530b

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 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 |filename|
      basename, newname, metadata = Propre.basename_newname_metadata(filename)
      if options[:dry]
        unchanged = basename == newname ? :green : :yellow
        puts "#{filename} -> #{newname}#{File.extname(filename)}".colorize(unchanged)
      else
        File.rename(filename, "#{newname}#{File.extname(filename)}")
      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

5 entries across 5 versions & 1 rubygems

Version Path
propre-0.3.1 bin/propre
propre-0.3.0 bin/propre
propre-0.2.2 bin/propre
propre-0.2.1 bin/propre
propre-0.2.0 bin/propre