class Dry::CLI::CommandRegistry::Node
Node
of the registry
@since 0.1.0 @api private
Attributes
after_callbacks[R]
@since 0.1.0 @api private
aliases[R]
@since 0.1.0 @api private
before_callbacks[R]
@since 0.1.0 @api private
children[R]
@since 0.1.0 @api private
command[R]
@since 0.1.0 @api private
parent[R]
@since 0.1.0 @api private
Public Class Methods
new(parent = nil)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 107 def initialize(parent = nil) @parent = parent @children = {} @aliases = {} @command = nil @before_callbacks = Chain.new @after_callbacks = Chain.new end
Public Instance Methods
alias!(key, child)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 144 def alias!(key, child) @aliases[key] = child end
aliases!(aliases)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 150 def aliases!(aliases) aliases.each do |a| parent.alias!(a, self) end end
children?()
click to toggle source
@since 0.7.0 @api private
# File lib/dry/cli/command_registry.rb, line 164 def children? children.any? end
leaf!(command)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 131 def leaf!(command) @command = command end
leaf?()
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 158 def leaf? !command.nil? end
lookup(token)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 125 def lookup(token) children[token] || aliases[token] end
put(parent, key)
click to toggle source
@since 0.1.0 @api private
# File lib/dry/cli/command_registry.rb, line 119 def put(parent, key) children[key] ||= self.class.new(parent) end
subcommands!(command)
click to toggle source
@since 0.7.0 @api private
# File lib/dry/cli/command_registry.rb, line 137 def subcommands!(command) command_class = command.is_a?(Class) ? command : command.class command_class.subcommands = children end