Class: Aspera::Cli::CommandSpec
- Inherits:
-
Struct
- Object
- Struct
- Aspera::Cli::CommandSpec
- Defined in:
- lib/aspera/cli/command_spec.rb
Overview
Declares a single command node in the flat registry.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Instance method (Symbol) or inline block (Proc) called when this is a leaf command.
-
#aliases ⇒ Object
readonly
Alternative names accepted for this command (each resolves to this command's id).
-
#arguments ⇒ Object
readonly
Positional arguments, in order.
-
#delegates_to ⇒ Object
readonly
Re-enter the command tree at this path.
-
#description ⇒ Object
readonly
User-facing help text.
-
#options ⇒ Object
readonly
Option names consumed by this command.
-
#parent ⇒ Object
readonly
Full path to parent; nil for root commands.
-
#query_schema ⇒ Object
readonly
Schema path for --query help; when set, the runner hints
--query=help. -
#transfer_paths ⇒ Object
readonly
File-list resolution delegated to TransferAgent; mutually exclusive with arguments.
Class Method Summary collapse
-
.action_method(path) ⇒ Symbol
Derive the implicit action method name from a path array.
Instance Method Summary collapse
-
#action_method_name ⇒ Symbol
Derive the implicit action method name from the full path.
-
#condition(value) ⇒ Object
Instance method returning Boolean; if false command is hidden from dispatch.
-
#delegate_instance(value) ⇒ Object
Instance method returning a different plugin object.
-
#entity_execute(value) ⇒ Object
Shorthand: expand to Base#entity_execute with these parameters.
-
#full_path ⇒ Array<Symbol>
Compute the full path as Array
from parent + id. -
#id(value) ⇒ Object
Unique identifier within its parent's namespace.
-
#initialize(**kwargs) ⇒ CommandSpec
constructor
A new instance of CommandSpec.
-
#setup(value) ⇒ Object
Instance method called before dispatching to children; returns Hash merged into ctx.
Constructor Details
#initialize(**kwargs) ⇒ CommandSpec
Returns a new instance of CommandSpec.
105 106 107 108 109 110 111 112 113 |
# File 'lib/aspera/cli/command_spec.rb', line 105 def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Instance method (Symbol) or inline block (Proc) called when this is a leaf command
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#aliases ⇒ Object (readonly)
Alternative names accepted for this command (each resolves to this command's id)
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#arguments ⇒ Object (readonly)
Positional arguments, in order. The first ArgumentSpec with type: :identifier is treated as the instance identifier for intermediate nodes (consumed in Phase A) and leaf nodes.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#delegates_to ⇒ Object (readonly)
Re-enter the command tree at this path
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#description ⇒ Object (readonly)
User-facing help text
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#options ⇒ Object (readonly)
Option names consumed by this command
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#parent ⇒ Object (readonly)
Full path to parent; nil for root commands
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#query_schema ⇒ Object (readonly)
Schema path for --query help; when set, the runner hints --query=help
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#transfer_paths ⇒ Object (readonly)
File-list resolution delegated to TransferAgent; mutually exclusive with arguments
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
Class Method Details
.action_method(path) ⇒ Symbol
Derive the implicit action method name from a path array. e.g. [:admin, :user, :list] -> :action_admin_user_list
120 121 122 |
# File 'lib/aspera/cli/command_spec.rb', line 120 def action_method(path) :"action_#{path.join('_')}" end |
Instance Method Details
#action_method_name ⇒ Symbol
Derive the implicit action method name from the full path.
133 134 135 |
# File 'lib/aspera/cli/command_spec.rb', line 133 def action_method_name self.class.action_method(full_path) end |
#condition=(value) ⇒ Object
Instance method returning Boolean; if false command is hidden from dispatch
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#delegate_instance=(value) ⇒ Object
Instance method returning a different plugin object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#entity_execute=(value) ⇒ Object
Shorthand: expand to Base#entity_execute with these parameters
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#full_path ⇒ Array<Symbol>
Compute the full path as Array
127 128 129 |
# File 'lib/aspera/cli/command_spec.rb', line 127 def full_path Array(parent) + [id] end |
#id=(value) ⇒ Object
Unique identifier within its parent's namespace
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |
#setup=(value) ⇒ Object
Instance method called before dispatching to children; returns Hash merged into ctx
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspera/cli/command_spec.rb', line 88 CommandSpec = Struct.new( :id, :parent, :description, :options, :arguments, :action, :setup, :delegates_to, :delegate_instance, :aliases, :entity_execute, :transfer_paths, :condition, :query_schema, keyword_init: true ) do def initialize(**kwargs) # Coerce each element of arguments: from Hash to ArgumentSpec if needed if kwargs[:arguments] kwargs[:arguments] = kwargs[:arguments].map do |a| a.is_a?(Hash) ? ArgumentSpec.new(**a) : a end end super end class << self # Derive the implicit action method name from a path array. # e.g. [:admin, :user, :list] -> :action_admin_user_list # @param path [Array<Symbol>] # @return [Symbol] def action_method(path) :"action_#{path.join('_')}" end end # Compute the full path as Array<Symbol> from parent + id. # @return [Array<Symbol>] def full_path Array(parent) + [id] end # Derive the implicit action method name from the full path. # @return [Symbol] def action_method_name self.class.action_method(full_path) end end |