Sha256: d20bb87f2f61a88f4f1149d1d77f52be1fec1ca18b1a187e6003e597d9bebe10

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

SCRIPT_DIR = File.expand_path("../scripts", __dir__)

def available_scripts
  @available_scripts ||= Dir.children(SCRIPT_DIR).sort.to_h do |script|
    desc = File.read(File.join(SCRIPT_DIR, script)).match(/synopsis(?:\(|\s+)['"](.*)['"]/)&.captures&.first
    [script, desc]
  end
end

def usage
  puts "Usage: multi_repo <script> [args]"
  puts "  script      Script to run"
  puts "  args        Arguments to pass to the script"
  puts "  -h, --help  Show this help message"
  puts
  puts "For help on a specific script, run:"
  puts "  multi_repo <script> --help"
  puts
  puts "Available scripts:"

  justify = available_scripts.keys.map(&:length).max + 2
  puts available_scripts.map { |script, desc| "  #{script.ljust(justify)} #{desc}" }.join("\n")
end

script, args = ARGV[0], ARGV[1..]

if script.nil? || script.empty? || script == "--help" || script == "-h"
  usage
  exit
end

fq_script = File.join(SCRIPT_DIR, script)
unless File.exist?(fq_script)
  puts "ERROR: script #{script.inspect} not found"
  puts
  usage
  exit 1
end

exec fq_script, *args

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
multi_repo-0.5.0 exe/multi_repo
multi_repo-0.4.0 exe/multi_repo
multi_repo-0.3.1 exe/multi_repo
multi_repo-0.3.0 exe/multi_repo
multi_repo-0.2.3 exe/multi_repo
multi_repo-0.2.2 exe/multi_repo