skeleton for jpi CLI.
This commit is contained in:
parent
6faaa029f0
commit
121fec02ad
4
bin/jpi
4
bin/jpi
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'jpi/cli'
|
||||
require 'jenkins/plugin/cli'
|
||||
|
||||
JPI::CLI.start
|
||||
Jenkins::Plugin::CLI.start ARGV
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
require 'thor'
|
||||
require 'jenkins/plugin/cli/formatting'
|
||||
|
||||
module Jenkins
|
||||
class Plugin
|
||||
class CLI < Thor
|
||||
extend Formatting
|
||||
|
||||
desc "help [COMMAND]", "get help for COMMAND, or for jpi itself"
|
||||
def help(command = nil)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
module Jenkins
|
||||
class Plugin
|
||||
class CLI < Thor
|
||||
module Formatting
|
||||
def task_help(shell, task_name)
|
||||
meth = normalize_task_name(task_name)
|
||||
task = all_tasks[meth]
|
||||
handle_no_task_error(meth) unless task
|
||||
|
||||
shell.say "usage: #{banner(task)}"
|
||||
shell.say
|
||||
class_options_help(shell, nil => task.options.map { |_, o| o })
|
||||
end
|
||||
|
||||
|
||||
def print_options(shell, options, grp = nil)
|
||||
return if options.empty?
|
||||
table = options.map do |option|
|
||||
prototype = if option.default
|
||||
" [#{option.default}]"
|
||||
elsif option.type == :boolean
|
||||
""
|
||||
elsif option.required?
|
||||
" #{option.banner}"
|
||||
else
|
||||
" [#{option.banner}]"
|
||||
end
|
||||
aliases = option.aliases.empty? ? "" : option.aliases.join(" ") + ","
|
||||
[aliases, "--#{option.name}#{prototype}", "\t",option.description]
|
||||
end
|
||||
shell.print_table(table, :ident => 2)
|
||||
shell.say
|
||||
end
|
||||
|
||||
def help(shell, task)
|
||||
list = printable_tasks
|
||||
print shell.set_color("jpi", :black, true)
|
||||
shell.say <<-USEAGE
|
||||
- tools to create, build, develop and release Jenkins plugins
|
||||
|
||||
Usage: jpi command [arguments] [options]
|
||||
|
||||
USEAGE
|
||||
|
||||
shell.say "Commands:"
|
||||
shell.print_table(list, :ident => 2, :truncate => true)
|
||||
shell.say
|
||||
class_options_help(shell)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue