#!/usr/bin/env ruby #run via terminal e.g. bundle exec ./bin/overview appversion -a require 'gli' require 'overview.rb' include GLI::App program_desc "Config management tool connecting Over's CI / CD toolchain" version Overview::VERSION subcommand_option_handling :normal arguments :strict =begin desc 'Describe some switch here' switch [:s,:switch] =end desc 'Sprint.ly API KEY' #default_value 'the default' arg_name 'API_KEY' flag [:sprintly_api_key] desc 'Sprint.ly USER' arg_name 'USER' flag [:sprintly_user] desc 'Github token' arg_name 'TOKEN' flag [:travis_token] desc 'Github token' arg_name 'TOKEN' flag [:github_token] desc 'Mark Sprint.ly tickets as deployed via Github' arg_name 'Describe arguments to deploy here' command :deploy do |c| c.desc 'Describe a switch to deploy' c.switch :s c.desc 'Describe a flag to deploy' c.default_value 'default' c.flag :f c.action do |global_options,options,args| # Your command logic here # If you have any errors, just raise them # raise "that command made no sense" puts "deploy command ran" end end desc 'Mark Sprint.ly tickets as released via Github Releases' arg_name 'Describe arguments to deploy here' command :release do |c| c.action do |global_options,options,args| # Your command logic here # If you have any errors, just raise them # raise "that command made no sense" puts "release command ran" end end desc 'Retrieve the changelog for the latest commit' #arg_name 'audience' command :changelog do |c| #c.desc 'Describe a switch to deploy' #c.switch :s c.desc "Audience receiving the changelog. Possible options are: alpha; beta; production" c.default_value 'production' c.flag :a c.action do |global_options,options,args| include Changelog Changelog::Log.new.display end end desc 'Derive app version from Github tag, release and branch, and build from CI server e.g. v2.8.6-pnginitialsize (5462)' arg_name 'github_token', :input command :appversion do |c| c.desc 'Semantic version only e.g. 0.1.1' c.switch :s c.desc 'Build number only e.g. 534' c.switch :b c.desc 'Version (no build) with branch e.g. 0.1.1-feature' c.switch :v c.desc 'Rubygem compatible version with build appended e.g. 0.1.1-feature-534' c.switch :r c.desc 'Google App Engine compatible version with build appended e.g. 0-1-1-feature-534' c.switch :a c.action do |global_options,options,args| include AppVersion if options[:s] puts AppVersion::Version.new.version(true).to_s elsif options[:b] puts AppVersion::Version.new.build_no.to_s elsif options[:v] puts AppVersion::Version.new.version.to_s elsif options[:r] puts "#{AppVersion::Version.new.version.to_s}.#{AppVersion::Version.new.build_no.to_s}" elsif options[:a] puts "#{AppVersion::Version.new.version.to_s}.#{AppVersion::Version.new.build_no.to_s}".gsub('.','-') else puts AppVersion::Version.new.to_s end end end pre do |global,command,options,args| ENV['GITHUB_TOKEN'] = global[:github_token] unless global[:github_token].nil? ENV['TRAVIS_TOKEN'] = global[:travis_token] unless global[:travis_token].nil? ENV['SPRINTLY_USER'] = global[:sprintly_user] unless global[:sprintly_user].nil? ENV['SPRINTLY_API_KEY'] = global[:sprintly_api_key] unless global[:sprintly_api_key].nil? # Pre logic here # Return true to proceed; false to abort and not call the # chosen command # Use skips_pre before a command to skip this block # on that command only true end post do |global,command,options,args| # Post logic here # Use skips_post before a command to skip this # block on that command only end on_error do |exception| # Error logic here # return false to skip default error handling true end exit run(ARGV)