Sha256: 7509d04be4bd5795b0113ffa6d8a5f09988ba46f1f6f7b8c743f4e5de40807c8

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require 'thor'

module Pronto
  class CLI < Thor
    require 'pronto'
    require 'pronto/version'

    desc 'exec', 'Run Pronto'

    method_option :commit,
                  type: :string,
                  default: nil,
                  aliases: '-c',
                  banner: 'Commit for the diff, defaults to master'

    method_option :runner,
                  type: :array,
                  default: [],
                  aliases: '-r',
                  banner: 'Run only the passed runners'

    method_option :formatter,
                  type: :string,
                  default: nil,
                  aliases: '-f',
                  banner: "Formatter, defaults to text.
                           Available: #{::Pronto::Formatter.names.join(', ')}"

    def exec
      gem_names = options[:runner].any? ? options[:runner] : ::Pronto.gem_names
      gem_names.each do |gem_name|
        require "pronto/#{gem_name}"
      end

      formatter = ::Pronto::Formatter.get(options[:formatter])
      puts ::Pronto.run(options[:commit], '.', formatter)
    rescue Rugged::RepositoryError
      puts '"pronto" should be run from a git repository'
    end

    desc 'list', 'Lists pronto runners that are available to be used'

    def list
      puts ::Pronto.gem_names
    end

    desc 'version', 'Show the Pronto version'
    map %w(-v --version) => :version

    def version
      puts "Pronto version #{::Pronto::VERSION}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pronto-0.1.4 lib/pronto/cli.rb
pronto-0.1.3 lib/pronto/cli.rb
pronto-0.1.2 lib/pronto/cli.rb