Class: Rosette::Client::Commands::DiffCommandArgs

Inherits:
Struct
  • Object
show all
Defined in:
lib/rosette/client/commands/diff_command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#diff_point_refObject

Returns the value of attribute diff_point_ref

Returns:

  • (Object)

    the current value of diff_point_ref



15
16
17
# File 'lib/rosette/client/commands/diff_command.rb', line 15

def diff_point_ref
  @diff_point_ref
end

#head_refObject

Returns the value of attribute head_ref

Returns:

  • (Object)

    the current value of head_ref



15
16
17
# File 'lib/rosette/client/commands/diff_command.rb', line 15

def head_ref
  @head_ref
end

#pathsObject

Returns the value of attribute paths

Returns:

  • (Object)

    the current value of paths



15
16
17
# File 'lib/rosette/client/commands/diff_command.rb', line 15

def paths
  @paths
end

Class Method Details

.from_argv(argv, repo) ⇒ Object

should probably use a parser for these args, since they’re pretty complicated currently no support for options like –name-only, etc



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rosette/client/commands/diff_command.rb', line 18

def self.from_argv(argv, repo)
  diff_point_ref = repo.rev_parse(argv[0] || 'refs/heads/master')
  paths = []

  if argv[1]
    if File.exist?(argv[1])
      paths << argv[1]
    else
      head_ref = argv[1] unless argv[1] == '--'
    end
  end

  head_ref ||= repo.rev_parse(repo.get_head)

  (2..argv.size).each do |i|
    next if argv[i] == '--'
    if argv[i] && File.exist?(argv[i])
      paths << argv[i]
    end
  end

  new(diff_point_ref, head_ref, paths)
end