Sha256: 9806e3cb4e03c0e1f4270cadf0adfd9ab93f4db17fe5eaab92faeff5ea2a4d20

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

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.deep_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.6 lib/ebooks_renamer/cli.rb
ebooks_renamer-0.2.5 lib/ebooks_renamer/cli.rb
ebooks_renamer-0.2.4 lib/ebooks_renamer/cli.rb