#!/usr/bin/env ruby require 'gli' require 'overview' include GLI::App include Overview program_desc "Config management tool connecting Over's CI / CD toolchain" version Overview::VERSION subcommand_option_handling :normal arguments :strict desc 'Describe some switch here' switch [:s,:switch] desc 'Describe some flag here' default_value 'the default' arg_name 'The name of the argument' flag [:f,:flagname] desc 'Describe deploy here' 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 '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| puts "alphalog command ran" 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.534' c.switch :r c.desc 'Github token' c.flag :g c.action do |global_options,options,args| ENV['GITHUB_TOKEN'] = options[:g] if options[:s] puts Overview::AppVersion.new.version(true).to_s elsif options[:b] puts Overview::AppVersion.new.build_no.to_s elsif options[:v] puts Overview::AppVersion.new.version.to_s elsif options[:r] puts "#{Overview::AppVersion.new.version.to_s}.#{Overview::AppVersion.new.build_no.to_s}" else puts Overview::AppVersion.new.to_s end end end pre do |global,command,options,args| # 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)