Module: Jenkins::Plugin::CLI::Formatting
- Included in:
- Jenkins::Plugin::CLI
- Defined in:
- lib/jenkins/plugin/cli/formatting.rb
Instance Method Summary collapse
- #help(shell, task) ⇒ Object
- #print_options(shell, options, grp = nil) ⇒ Object
- #task_help(shell, task_name) ⇒ Object
Instance Method Details
#help(shell, task) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jenkins/plugin/cli/formatting.rb', line 36 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 (shell) end |
#print_options(shell, options, grp = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jenkins/plugin/cli/formatting.rb', line 17 def (shell, , grp = nil) return if .empty? table = .map do |option| prototype = if option.default " [#{option.default}]" elsif option.type == :boolean "" elsif option.required? " #{option.}" else " [#{option.}]" 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 |
#task_help(shell, task_name) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/jenkins/plugin/cli/formatting.rb', line 6 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: #{(task)}" shell.say (shell, nil => task..map { |_, o| o }) end |