Sha256: d010290dad38a6d95dc75daeafd8ed354daf8ba8f17152a00146f48a69c7049e

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require "thor"
require "agile_utils"
require_relative "ebooks_renamer"
module EbooksRenamer
  class CLI < Thor
    desc "rename", "Rename ebooks based on given criteria"
    method_option *AgileUtils::Options::BASE_DIR
    method_option *AgileUtils::Options::RECURSIVE
    method_option *AgileUtils::Options::VERSION
    method_option :sep_string,
                  aliases: "-s",
                  desc: "Separator string between words in filename",
                  default: "."
    method_option :commit,
                  aliases: "-c",
                  desc: "Make change permanent",
                  type: :boolean,
                  default: false
    def rename
      opts = options.symbolize_keys
      if opts[:version]
        puts "You are using EbooksRenamer version #{EbooksRenamer::VERSION}"
        exit
      end
      # Add the default supported extensions
      opts.merge!(exts: %w[pdf epub mobi])
      puts "Your options #{opts}"
      EbooksRenamer.rename(opts)
    end

    desc "usage", "Display help screen"
    def usage
      puts <<-EOS

Usage:
  ebooks_renamer

Options:
  -b, [--base-dir=BASE_DIR]                # Base directory
                                           # Default: . (current directory)
  -r, [--recursive], [--no-recursive]      # Search for files recursively
                                           # Default: true
  -v, [--version], [--no-version]          # Display version information
  -s, [--sep-string=SEP_STRING]            # Separator string between words in filename
                                           # Default: .
  -c, [--commit], [--no-commit]            # Make change permanent

Rename ebooks based on given criteria
      EOS
    end

    default_task :usage
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ebooks_renamer-0.2.2 lib/ebooks_renamer/cli.rb
ebooks_renamer-0.1.5 lib/ebooks_renamer/cli.rb
ebooks_renamer-0.1.4 lib/ebooks_renamer/cli.rb