class Dracula::Structure
Attributes
namespace[R]
Public Class Methods
new(namespace)
click to toggle source
# File lib/dracula/structure.rb, line 6 def initialize(namespace) @namespace = namespace end
Public Instance Methods
generate()
click to toggle source
# File lib/dracula/structure.rb, line 10 def generate { :name => namespace.name.to_s, :commands => @namespace.commands.map { |cmd| command_docs(cmd) }, :namespaces => @namespace.subcommands.map { |sc| Dracula::Structure.new(sc).generate } } end
Private Instance Methods
command_docs(command)
click to toggle source
# File lib/dracula/structure.rb, line 20 def command_docs(command) { :name => command.name, :desc => command.description, :long_desc => command.long_desc.to_s, :shell => command_shell(command), :flags => command.options.map do |option| { :name => option.name.to_s, :required => option.required?, :type => option.type.to_s, :alias => option.alias_name, :default => option.default_value, :desc => option.description.to_s } end } end
command_shell(command)
click to toggle source
shows how to calll the command from the shell
# File lib/dracula/structure.rb, line 40 def command_shell(command) args = command.arguments.join(" ") options = command.options.select(&:required?).map(&:long_name_banner).join(" ") elements = [ Dracula.program_name, command.full_name, args, options ] elements.select { |element| element != "" }.join(" ") end