lib/jenkins/builder/cli.rb in jenkins-builder-0.2.1 vs lib/jenkins/builder/cli.rb in jenkins-builder-0.2.2
- old
+ new
@@ -5,20 +5,35 @@
module Jenkins
module Builder
class CLI < ::Thor
class << self
+ def main(args)
+ validate_fzf!
+ @config = Jenkins::Builder::Config.new
+ create_alias_commands(@config.aliases || [])
+ start(args)
+ end
def create_alias_commands(aliases)
aliases.each do |name, command|
desc "#{name}", "Alias for: `#{command}'"
define_method name do |*args|
self.class.start(Shellwords.split(command) + args)
end
end
end
+
+ def validate_fzf!
+ `fzf --version`
+ rescue Errno::ENOENT
+ raise 'Required command fzf is not installed.'
+ end
+
end
+ class_option :service, type: :string, aliases: ['-s'], desc: 'Specify service name'
+
desc 'setup [-e]', 'Setup URL, username and password, or open config file in an editor when -e specified.'
option :edit, type: :boolean, aliases: ['-e'], desc: 'open config file in an editor'
def setup
if options[:edit]
editor = ENV['VISUAL'] || ENV['EDITOR'] || "vim"
@@ -37,11 +52,11 @@
option :password, type: :boolean, aliases: ['-p'], desc: 'show password also.'
def info
Jenkins::Builder::App.new.print_info(options)
end
- desc 'build [-s] [-f] <JOB_IDENTIFIERS>', 'Build jobs'
- option :silent, type: :boolean, aliases: ['-s'], desc: 'suppress console output.'
+ desc 'build [-q] [-f] <JOB_IDENTIFIERS>', 'Build jobs'
+ option :quiet, type: :boolean, aliases: ['-q'], 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