Sha256: 8996d090f71f94e7a956e6745c813c4e37a5c3c8c86acddb87d7a3e7f5e8875f

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

require 'thor'

class Thor
  include Thor::Base

  class << self

    def help(shell, subcommand = false)
      list = printable_tasks(true, subcommand)
      Thor::Util.thor_classes_in(self).each do |klass|
        list += klass.printable_tasks(false)
      end
      list.sort!{ |a,b| a[0] <=> b[0] }

      shell.say "Commands:"
      shell.print_table(list, :indent => 2, :truncate => true)
      shell.say
      class_options_help(shell)
    end

    def subcommand_help(cmd)
      desc "help <command>", "Describe subcommands or one specific subcommand"
      class_eval <<-RUBY
        def help(task = nil, subcommand = true); super; end
      RUBY
    end
  end

  desc "help <command>", "Describe available commands or one specific command"
  def help(task = nil, subcommand = false)
    task ? self.class.task_help(shell, task) : self.class.help(shell, subcommand)
  end
end # Thor

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_cli-0.3.1 lib/github_cli/thor_ext.rb