Sha256: 5f38555cebadae41b444c9ce332edb6ef342f949880cf88079c7dd47f409e4d5

Contents?: true

Size: 849 Bytes

Versions: 13

Compression:

Stored size: 849 Bytes

Contents

require 'optparse'

module Papers

  class CLI

    def run
      if parse_options[:generate]
        begin
          generator = Papers::ManifestGenerator.new
          generator.generate!
        rescue Papers::FileExistsError => e
          warn "Error: 'papers_manifest.yml' already exists at '#{e.message}'. Aborting..."
        end
      end
    end

    private

    def parse_options
      options = {}
      OptionParser.new do |opts|
        opts.banner = "Usage: papers [options]"

        opts.on("-g", "--generate", "Generate papers_manifest.yml") do |v|
          options[:generate] = v
        end

        opts.on_tail( '-h', '--help', 'Display this screen' ) do |v|
          p opts
          exit
        end
        @avail_opts = opts
      end.parse!

      p @avail_opts if options.empty?

      return options
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
papers-2.3.0 lib/papers/cli.rb
papers-2.2.0 lib/papers/cli.rb
papers-2.1.0 lib/papers/cli.rb
papers-2.0.0 lib/papers/cli.rb
papers-1.4.0 lib/papers/cli.rb
papers-1.3.2 lib/papers/cli.rb
papers-1.3.1 lib/papers/cli.rb
papers-1.3.0 lib/papers/cli.rb
papers-1.2.0 lib/papers/cli.rb
papers-1.1.0 lib/papers/cli.rb
papers-1.0.3 lib/papers/cli.rb
papers-1.0.2 lib/papers/cli.rb
papers-1.0.1 lib/papers/cli.rb