Method: Bundler::Thor::Command#formatted_usage
- Defined in:
- lib/bundler/vendor/thor/lib/thor/command.rb
#formatted_usage(klass, namespace = true, subcommand = false) ⇒ Object
Returns the formatted usage by injecting given required arguments and required options into the given usage.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/bundler/vendor/thor/lib/thor/command.rb', line 42 def formatted_usage(klass, namespace = true, subcommand = false) if ancestor_name formatted = "#{ancestor_name} ".dup # add space elsif namespace namespace = klass.namespace formatted = "#{namespace.gsub(/^(default)/, '')}:".dup end formatted ||= "#{klass.namespace.split(':').last} ".dup if subcommand formatted ||= "".dup Array(usage).map do |specific_usage| formatted_specific_usage = formatted formatted_specific_usage += required_arguments_for(klass, specific_usage) # Add required options formatted_specific_usage += " #{}" # Strip and go! formatted_specific_usage.strip end.join("\n") end |