#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w(.. lib)) require 'incr' require 'gli' include GLI::App program_desc('Tasteful utility to increment the version number and create a corresponding git tag.') version(Incr::VERSION) flag([:d, :version_file_dir], default_value: '.', desc: 'Directory where to search for version file') flag([:t, :tag_name_pattern], default_value: 'v%s', desc: 'Pattern for the tag name') switch(:commit, default_value: true, desc: 'Commit changes') switch(:tag, default_value: true, desc: 'Create a git tag') pre do |global, command, options, args| if args.length != 1 || !['major', 'minor', 'patch'].any? {|segment| args.include?(segment)} warn('expecting a single argument: major, minor or patch.') return false end true end # NPM Support desc('Increment the version of your NPM package.') command :npm do |cmd| cmd.action do |global_options, options, args| npm = Incr::Command::Npm.new(args, global_options) npm.execute end end # Elixir Support desc('Increment the version of your Mix package.') command :mix do |cmd| cmd.action do |global_options, options, args| mix = Incr::Command::Mix.new(args, global_options) mix.execute end end exit(run(ARGV))