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.



108
109
110
111
112
113
114
115
116
# File 'lib/aspera/cli/command_spec.rb', line 108

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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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)



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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.



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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)


123
124
125
# File 'lib/aspera/cli/command_spec.rb', line 123

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)


136
137
138
# File 'lib/aspera/cli/command_spec.rb', line 136

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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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>)


130
131
132
# File 'lib/aspera/cli/command_spec.rb', line 130

def full_path
  Array(parent) + [id]
end

#id=(value) ⇒ Object

Unique identifier within its parent's namespace



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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



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
137
138
139
# File 'lib/aspera/cli/command_spec.rb', line 92

CommandSpec = Struct.new(
  :id,
  :parent,
  :description,
  :options,
  :arguments,
  :action,
  :setup,
  :delegates_to,
  :delegate_instance,
  :aliases,
  :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