#!/usr/bin/ruby require_relative("../lib/yes_ship_it.rb") options = {} option_parser = OptionParser.new do |opts| opts.banner = "Usage: yes_ship_it [options] [command]" opts.separator "" opts.separator "Commands:" opts.separator " changelog - show change log since last release" opts.separator "" opts.separator "Specific options:" opts.on("--dry-run", "Just pretend. Don't change anything.") do |v| options[:dry_run] = v end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end option_parser.parse! config_file = "yes_ship_it.conf" if !File.exist?(config_file) STDERR.puts("Unable to find file `yes_ship_it.conf`. I need it.") exit 1 end if ARGV == ["changelog"] engine = YSI::Engine.new engine.check_assertion(YSI::Version) tag = `git tag`.split("\n").last system("git log #{tag}..HEAD") exit 0 elsif ARGV.empty? puts "Shipping..." puts engine = YSI::Engine.new engine.dry_run = options[:dry_run] begin engine.read(config_file) exit engine.run rescue YSI::Error => e STDERR.puts e exit 1 end else $stderr.puts "Unrecognized arguments: #{ARGV.join(" ")}" puts option_parser exit 1 end