Sha256: 7a65f167abdb815b700d5dd54fea686fdbe37617d91fcbb1d5eaa78c6bbb8f59

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require 'thor'
require 'eucalypt/app'
require 'eucalypt/helpers/colorize'

module Eucalypt
  module List
    include Eucalypt::Helpers
    using Colorize

    INDENT = 2.freeze

    def help(shell, subcommand = false)
      list = printable_commands(true, subcommand)
      Thor::Util.thor_classes_in(self).each do |klass|
        list += klass.printable_commands(false)
      end

      list.reject! do |l|
        cmd = l.first
        cmd.include?('help') || cmd.include?('-H')
      end
      list.map {|l| l.last.sub!(?#, '·'.colorize(:pale_blue, :bold)+'›')}

      if defined?(@package_name) && @package_name
        shell.say "#{@package_name} commands:"
      else
        shell.say
        shell.say "#{"Commands".colorize(:bold)}:"
      end

      shell.print_table(list, indent: INDENT, truncate: false)
      shell.say
      class_options_help(shell)

      shell.say "For more information about a specific command, use #{"eucalypt -H".colorize(:pale_blue)}."
      shell.say "Example: eucalypt -H generate scaffold".colorize(:grey)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eucalypt-0.2.1 lib/eucalypt/list.rb
eucalypt-0.2.0 lib/eucalypt/list.rb
eucalypt-0.1.3 lib/eucalypt/list.rb
eucalypt-0.1.2 lib/eucalypt/list.rb
eucalypt-0.1.1 lib/eucalypt/list.rb
eucalypt-0.1.0 lib/eucalypt/list.rb