Class: Inch::CLI::Command::Diff

Inherits:
Base
  • Object
show all
Includes:
Utils::ShellHelper
Defined in:
lib/inch/cli/command/diff.rb

Constant Summary collapse

EXIT_STATUS_FAILED =
1

Constants inherited from Base

Base::EXIT_STATUS_SUCCESS

Instance Attribute Summary

Attributes inherited from Base

#codebase

Instance Method Summary collapse

Methods included from Utils::ShellHelper

#git, #sh

Methods inherited from Base

#initialize, #name, register_command_as, run

Methods included from TraceHelper

#ui

Constructor Details

This class inherits a constructor from Inch::CLI::Command::Base

Instance Method Details

#descriptionObject



15
16
17
# File 'lib/inch/cli/command/diff.rb', line 15

def description
  'Shows a diff'
end

#exit_statusObject



19
20
21
# File 'lib/inch/cli/command/diff.rb', line 19

def exit_status
  @exit_status || super
end

#run(*args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/inch/cli/command/diff.rb', line 27

def run(*args)
  @options.parse(args)
  @options.verify

  before_rev, after_rev = revisions[0], revisions[1]
  diff = API::Diff.new(work_dir, to_config(@options),
                       before_rev, after_rev)

  Output::Diff.new(@options, diff.comparer)

  @exit_status = EXIT_STATUS_FAILED if diff.failed?
end

#usageObject



23
24
25
# File 'lib/inch/cli/command/diff.rb', line 23

def usage
  'Usage: inch diff [REV..[REV]] [options]'
end