Sha256: 155e607343b3ae7e529d0c1782212ea549b65d5356a7c4c4be9d183dd30771ba

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

module Rpub
  module Commands
    class Clean < Base
      include CompilationHelpers

      identifier 'clean'

      def invoke
        super
        remove create_book.filename
        remove 'preview.html'
      end

    private

      def parser
        OptionParser.new do |opts|
          opts.banner = <<-EOS
Usage: rpub clean [-d]'

Clean up all generated files, such as the standard generated .epub
file, package files and preview files.

Options:
EOS

          opts.separator ''

          opts.on '-d', '--dry-run', 'Dry-run: only list files to be removed' do
            @dry_run = true
          end

          opts.separator ''
          opts.separator 'Generic options:'
          opts.separator ''

          opts.on_tail '-h', '--help', 'Display this message' do
            puts opts
            exit
          end
        end
      end

      def remove(filename)
        if File.exist?(filename)
          unless @dry_run
            File.unlink(filename)
          else
            puts filename
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rpub-0.4.0 lib/rpub/commands/clean.rb
rpub-0.3.0 lib/rpub/commands/clean.rb
rpub-0.2.1 lib/rpub/commands/clean.rb
rpub-0.2.0 lib/rpub/commands/clean.rb
rpub-0.1.0 lib/rpub/commands/clean.rb