lib/jenkins/builder/cli.rb in jenkins-builder-0.1.4 vs lib/jenkins/builder/cli.rb in jenkins-builder-0.1.5

- old
+ new

@@ -40,11 +40,16 @@ end desc 'build [-s] [-f] <JOB_IDENTIFIERS>', 'Build jobs' option :silent, type: :boolean, aliases: ['-s'], desc: 'suppress console output.' option :failfast, type: :boolean, aliases: ['-f'], desc: 'stop immediately when building fails.' + option :version, type: :boolean, aliases: ['-v'], desc: 'Show version.' def build(*jobs) + if options[:version] + puts Jenkins::Builder::VERSION + exit + end app = Jenkins::Builder::App.new(options) if jobs.empty? jobs = fzf(app.fetch_all_jobs) exit if jobs.empty? job = jobs.first @@ -79,10 +84,15 @@ desc 'refresh-jobs-cache', 'Refresh cache of job names' def refresh_jobs_cache Jenkins::Builder::App.new.refresh_jobs_cache end + desc 'version', 'Print version' + def version + puts Jenkins::Builder::VERSION + end + default_task :build no_commands do def read_text(prompt) print "#{prompt}" @@ -98,9 +108,10 @@ end def fzf(lines) IO.popen('fzf', 'r+') do |p| p.puts(lines.join("\n")) + p.close_write p.readlines.map(&:chomp) end end end end