Class: MultiRepo::InspectCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/multirepo/commands/inspect-command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#ensure_in_work_tree, #ensure_multirepo_enabled, #ensure_multirepo_tracked, #install_hooks, #multirepo_enabled_dependencies, report_error, #uninstall_hooks, #update_gitconfig

Constructor Details

#initialize(argv) ⇒ InspectCommand

Returns a new instance of InspectCommand.



18
19
20
21
22
# File 'lib/multirepo/commands/inspect-command.rb', line 18

def initialize(argv)
  stat = argv.shift_argument
  @stat = stat ? stat.downcase : nil
  super
end

Class Method Details

.optionsObject



14
15
16
# File 'lib/multirepo/commands/inspect-command.rb', line 14

def self.options
  [['<stat name>', 'The name of the statistic to output.']].concat(super)
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/multirepo/commands/inspect-command.rb', line 37

def run
  ensure_in_work_tree
  
  case @stat
  when InspectCommandStats::VERSION
    puts MetaFile.new(".").load.version
  when InspectCommandStats::TRACKED
    puts Utils.multirepo_tracked?(".").to_s
  end
end

#statsObject



29
30
31
# File 'lib/multirepo/commands/inspect-command.rb', line 29

def stats
  InspectCommandStats.constants.map { |s| InspectCommandStats.const_get(s) }
end

#valid_stat?(stat) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/multirepo/commands/inspect-command.rb', line 33

def valid_stat?(stat)
  stats.include?(stat)
end

#validate!Object



24
25
26
27
# File 'lib/multirepo/commands/inspect-command.rb', line 24

def validate!
  super
  help! "You must provide a valid stat name. Available stats: \n    #{stats.join(', ')}" unless valid_stat?(@stat)
end