Class: MultiRepo::OpenCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/multirepo/commands/open-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) ⇒ OpenCommand

Returns a new instance of OpenCommand.



20
21
22
23
# File 'lib/multirepo/commands/open-command.rb', line 20

def initialize(argv)
  @repo_selection = RepoSelection.new(argv)
  super
end

Class Method Details

.optionsObject



12
13
14
15
16
17
18
# File 'lib/multirepo/commands/open-command.rb', line 12

def self.options
  [
    ['[--all]', 'Open the main repository and all dependencies.'],
    ['[--main]', 'Open the main repository.'],
    ['[--deps]', 'Open dependencies.']
  ].concat(super)
end

Instance Method Details

#open_dependenciesObject



49
50
51
52
53
# File 'lib/multirepo/commands/open-command.rb', line 49

def open_dependencies
  ConfigFile.new(".").load_entries.each do |entry|
    Utils.reveal_in_default_file_browser(entry.repo.path)
  end
end

#open_mainObject



45
46
47
# File 'lib/multirepo/commands/open-command.rb', line 45

def open_main
  Utils.reveal_in_default_file_browser(".")
end

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/multirepo/commands/open-command.rb', line 30

def run
  ensure_in_work_tree
  ensure_multirepo_enabled
  
  case @repo_selection.value
  when RepoSelection::MAIN
    open_main
  when RepoSelection::DEPS
    open_dependencies
  when RepoSelection::ALL
    open_dependencies
    open_main
  end
end

#validate!Object



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

def validate!
  super
  help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
end