3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/petra/patches/thor/command.rb', line 3
def formatted_usage(klass, namespace = true, subcommand = false)
if namespace
namespace = klass.namespace
formatted = "#{namespace.gsub(/^(default)/,'')}:"
end
formatted = "#{klass.namespace.split(':').last} " if subcommand
formatted ||= ""
if !subcommand and klass.ancestors.include?( Petra::CLI::Subcommand )
formatted << "#{ klass.command_invocation } "
end
formatted << if klass && !klass.arguments.empty?
usage.to_s.gsub(/^#{name}/) do |match|
match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
end
else
usage.to_s
end
formatted << " #{required_options}"
formatted.strip
end
|