Class: Rails::Diff::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/rails/diff/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


12
# File 'lib/rails/diff/cli.rb', line 12

def self.exit_on_failure? = true

Instance Method Details

#__versionObject



58
59
60
# File 'lib/rails/diff/cli.rb', line 58

def __version
  puts VERSION
end

#dotfilesObject



31
32
33
34
35
# File 'lib/rails/diff/cli.rb', line 31

def dotfiles
  dotfiles = `git ls-files --cached --others --exclude-standard -- '.*'`.split("\n")

  file(*dotfiles)
end

#file(*files) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails/diff/cli.rb', line 15

def file(*files)
  abort "Please provide at least one file to compare" if files.empty?
  ENV["DEBUG"] = "true" if options[:debug]

  diff = Rails::Diff.file(
    *files,
    no_cache: options[:no_cache],
    commit: options[:commit],
    new_app_options: options[:new_app_options]
  )
  return if diff.empty?

  options[:fail_on_diff] ? abort(diff) : puts(diff)
end

#generated(generator_name, *args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rails/diff/cli.rb', line 40

def generated(generator_name, *args)
  ENV["DEBUG"] = "true" if options[:debug]
  diff = Rails::Diff.generated(
    generator_name,
    *args,
    no_cache: options[:no_cache],
    skip: options[:skip],
    only: options[:only],
    commit: options[:commit],
    new_app_options: options[:new_app_options]
  )
  return if diff.empty?

  options[:fail_on_diff] ? abort(diff) : puts(diff)
end