Sha256: 069d9bf5e6ac62c01b946dcabf0bb6ee913d35f2b01eba5a883ecf58c88d0166

Contents?: true

Size: 1.37 KB

Versions: 22

Compression:

Stored size: 1.37 KB

Contents

require 'term/ansicolor'

module Hudson
  class CLI < Thor
    module Formatting
      module ClassMethods
        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 })
          # shell.say task.description
          # shell.say
        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.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
      end

      module InstanceMethods
        def c
          Term::ANSIColor
        end
      end

      def self.included(receiver)
        receiver.extend         ClassMethods
        receiver.send :include, InstanceMethods
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hudson-0.5.0 lib/hudson/cli/formatting.rb
hudson-0.3.1 lib/hudson/cli/formatting.rb
hudson-0.3.0 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.19 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.18 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.17 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.16 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.15 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.14 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.13 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.12 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.11 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.10 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.9 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.8 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.7 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.6 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.5 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.4 lib/hudson/cli/formatting.rb
hudson-0.3.0.beta.3 lib/hudson/cli/formatting.rb