Class: Aspera::Cli::CommandSpec

Inherits:
Struct
  • Object
show all
Defined in:
lib/aspera/cli/command_spec.rb

Overview

Declares a single command node in the flat registry.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#actionObject (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

#aliasesObject (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

#argumentsObject (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_toObject (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

#descriptionObject (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

#optionsObject (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

#parentObject (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_schemaObject (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_pathsObject (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

Parameters:

  • path (Array<Symbol>)

Returns:

  • (Symbol)


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_nameSymbol

Derive the implicit action method name from the full path.

Returns:

  • (Symbol)


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_pathArray<Symbol>

Compute the full path as Array from parent + id.

Returns:

  • (Array<Symbol>)


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