Module: BundlerDiff

Defined in:
lib/bundler_diff.rb,
lib/bundler_diff/cli.rb,
lib/bundler_diff/version.rb,
lib/bundler_diff/formatter/default.rb,
lib/bundler_diff/formatter/md_table.rb

Defined Under Namespace

Modules: Formatter Classes: CLI

Constant Summary collapse

VERSION =
'0.6.1'

Class Method Summary collapse

Class Method Details

.formattersObject



11
12
13
14
15
16
# File 'lib/bundler_diff.rb', line 11

def formatters
  @formatters ||= {
    default: Formatter::Default,
    md_table: Formatter::MdTable
  }
end

.parse_options(args) ⇒ Object

rubocop:disable Metrics/MethodLength



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bundler_diff.rb', line 18

def parse_options(args) # rubocop:disable Metrics/MethodLength
  options = {}

  opt = OptionParser.new
  opt.banner = 'Usage: bundle diff [options]'
  opt.on('-c', '--commit COMMIT', 'Specify a commit') { |val| options[:commit] = val }
  formatter_desc = [
    'Choose a formatter',
    '  default',
    '  md_table'
  ]
  opt.on('-f', '--format FORMATTER', *formatter_desc) do |val|
    options[:format] = val.to_sym
  end
  opt.on('--escape-json', 'Escape output as a JSON string') do |val|
    options[:escape_json] = val
  end
  opt.on('--access-token ACCESS_TOKEN', 'Set access token for GitHub API') do |val|
    options[:access_token] = val
  end

  opt.on('-v', '--version', 'Display the version') { options[:version] = true }

  remaining_args = opt.parse(args)
  options[:commit] ||= remaining_args.shift
  options
end