Class: Diffstitch::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/diffstitch/cli.rb

Constant Summary collapse

OUTPUT_BASE =
File.join('.diffstitch', 'output')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(argv = ARGV) ⇒ Object



10
11
12
# File 'lib/diffstitch/cli.rb', line 10

def self.start(argv = ARGV)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/diffstitch/cli.rb', line 14

def run(argv)
  options = parse_options!(argv)
  validate_repo!
  validate_args!(argv)

  base     = argv[0]
  branches = argv[1..]

  verify_refs!(base, branches)

  title      = options[:title] || "diffstitch: #{branches.join(' | ')} vs #{base}"
  output_dir = options[:output] || derived_output(base, branches)
  diffs      = collect_diffs(base, branches)

  Generator.new(base: base, branches: branches, diffs: diffs, title: title).write(output_dir)

  index = File.expand_path(File.join(output_dir, 'index.html'))
  puts "Generated: #{index}"
  open_in_browser(index) if options[:open]
end