Class: LabelWeaver::CLI::Commands::Diff

Inherits:
Sod::Command
  • Object
show all
Defined in:
lib/label_weaver/cli/commands/diff.rb

Instance Method Summary collapse

Instance Method Details

#callObject



17
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
# File 'lib/label_weaver/cli/commands/diff.rb', line 17

def call(*)
  @file_path = context.input[:file]

  case context.input[:format] || "unified"
  when "unified"
    TTY::Pager.page do |pager|
      changed_files.each do |repository_file, project_file|
        pager.write "          \n          \#{\"*\" * (project_file.to_s.length + 4)}\n          * \#{project_file} *\n          \#{\"*\" * (project_file.to_s.length + 4)}\n\n        EOS\n\n        pager.write Diffy::Diff.new(repository_file.to_s, project_file.to_s, source: \"files\", context: 3).to_s(:color)\n      end\n    end\n  when \"patch\"\n    changed_files.each do |repository_file, project_file|\n      puts Diffy::Diff.new(repository_file.to_s, project_file.to_s, source: \"files\", context: 0, include_diff_info: true)\n    end\n  else\n    logger.error \"Unknown format: \#{context.input[:format]}\"\n  end\n  logger.info context.input.inspect\nend\n"