Module: Thor::FormattedUsageOverride

Defined in:
lib/jets/thor/base.rb

Instance Method Summary collapse

Instance Method Details

#formatted_usage(klass, namespace = true, subcommand = false) ⇒ Object



58
59
60
61
62
# File 'lib/jets/thor/base.rb', line 58

def formatted_usage(klass, namespace = true, subcommand = false)
  usage = super
  # Namespace subcommands separate by colon instead of space
  items = formatted_usage_by_colons(usage)
end

#formatted_usage_by_colons(input) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/jets/thor/base.rb', line 64

def formatted_usage_by_colons(input)
  words = input.split(/\s+/)

  formatted = words.map.with_index do |word, index|
    next_word = words[index + 1]
    if next_word.nil? || next_word == next_word.upcase
      "#{word} "
    else
      "#{word}:"
    end
  end

  formatted.join.gsub(": ", ":").strip
end