class Gb::Forall

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/commands/forall.rb, line 20
def initialize(argv)
  @command = argv.option('c')
  super
end
options() click to toggle source
Calls superclass method
# File lib/commands/forall.rb, line 14
def self.options
  [
      ["--c", "执行命令"],
  ].concat(super)
end

Public Instance Methods

run_in_config() click to toggle source
# File lib/commands/forall.rb, line 32
def run_in_config

  self.gb_config.projects.each do |project|
    project_path = File.expand_path(project.name, './')

    if File.exist?(project_path)
      info "'#{@command}' For project '#{project.name}'..."
      g = Git.open(project_path)
      Dir.chdir(project_path) do
        result = `#{@command}`
        puts result
      end
      puts
    else
      error "please run 'gb init first."
      break
    end
  end
end
validate!() click to toggle source
Calls superclass method
# File lib/commands/forall.rb, line 25
def validate!
  super
  if @command.nil?
    help! 'command is required.'
  end
end