Class: Kube::Ctl::CommandTree::Node
- Inherits:
-
Object
- Object
- Kube::Ctl::CommandTree::Node
- Defined in:
- lib/kube/ctl/command_tree/node.rb
Instance Attribute Summary collapse
-
#inherited_options ⇒ Object
readonly
Returns the value of attribute inherited_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#subcommands ⇒ Object
readonly
Returns the value of attribute subcommands.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #add_subcommand(node) ⇒ Object
- #find_subcommand(token) ⇒ Object
-
#initialize(name:, options: [], inherited_options: [], usage: nil) ⇒ Node
constructor
A new instance of Node.
-
#known_flags ⇒ Object
Merge own + inherited flags.
Constructor Details
#initialize(name:, options: [], inherited_options: [], usage: nil) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 |
# File 'lib/kube/ctl/command_tree/node.rb', line 7 def initialize(name:, options: [], inherited_options: [], usage: nil) @name = name @options = index_flags() @inherited_options = index_flags() @subcommands = {} @usage = usage end |
Instance Attribute Details
#inherited_options ⇒ Object (readonly)
Returns the value of attribute inherited_options.
5 6 7 |
# File 'lib/kube/ctl/command_tree/node.rb', line 5 def @inherited_options end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/kube/ctl/command_tree/node.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/kube/ctl/command_tree/node.rb', line 5 def @options end |
#subcommands ⇒ Object (readonly)
Returns the value of attribute subcommands.
5 6 7 |
# File 'lib/kube/ctl/command_tree/node.rb', line 5 def subcommands @subcommands end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/kube/ctl/command_tree/node.rb', line 5 def usage @usage end |
Instance Method Details
#add_subcommand(node) ⇒ Object
15 16 17 |
# File 'lib/kube/ctl/command_tree/node.rb', line 15 def add_subcommand(node) @subcommands[node.name] = node end |
#find_subcommand(token) ⇒ Object
19 20 21 |
# File 'lib/kube/ctl/command_tree/node.rb', line 19 def find_subcommand(token) @subcommands[token] end |
#known_flags ⇒ Object
Merge own + inherited flags. Inherited is “inherited from ancestors”, in kubectl’s YAML it’s already flattened per command.
25 26 27 |
# File 'lib/kube/ctl/command_tree/node.rb', line 25 def known_flags @options.merge(@inherited_options) end |