Class: Aspera::Cli::ArgumentSpec
- Inherits:
-
Struct
- Object
- Struct
- Aspera::Cli::ArgumentSpec
- Defined in:
- lib/aspera/cli/command_spec.rb
Overview
Declares a positional argument consumed by a command.
Declaration order in a command's arguments: array defines parsing order.
Mandatory arguments must come before optional ones.
Instance Attribute Summary collapse
-
#allowed ⇒ Object
readonly
Allowed Symbol values; when set, type is forced to Symbol and accept_list is applied.
-
#description ⇒ Object
readonly
User-facing description.
-
#multiple ⇒ Object
readonly
true: consume all remaining; String: consume until named marker.
-
#schema ⇒ Object
readonly
JSON schema name for validation and --help introspection.
-
#type ⇒ Object
readonly
Validated type; :identifier triggers instance_identifier.
Instance Method Summary collapse
-
#bulk(value) ⇒ Object
When true, wraps read+loop for bulk mode (Array if --bulk yes).
-
#default(value) ⇒ Object
Default value when mandatory: false and no argument provided.
-
#initialize(**kwargs) ⇒ ArgumentSpec
constructor
A new instance of ArgumentSpec.
-
#interactive(value) ⇒ Object
When true, sets ask_missing_mandatory before resolving so interactive prompting is triggered when no CLI args are provided.
-
#lookup(value) ⇒ Object
Instance method name for percent-selector resolution (only used when type: :identifier).
-
#mandatory(value) ⇒ Object
Default true; optional args must come after all mandatory ones.
-
#name(value) ⇒ Object
Name used in help and error messages.
Constructor Details
#initialize(**kwargs) ⇒ ArgumentSpec
Returns a new instance of ArgumentSpec.
34 35 36 37 38 39 40 |
# File 'lib/aspera/cli/command_spec.rb', line 34 def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end |
Instance Attribute Details
#allowed ⇒ Object (readonly)
Allowed Symbol values; when set, type is forced to Symbol and accept_list is applied
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#description ⇒ Object (readonly)
User-facing description
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#multiple ⇒ Object (readonly)
true: consume all remaining; String: consume until named marker
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#schema ⇒ Object (readonly)
JSON schema name for validation and --help introspection
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#type ⇒ Object (readonly)
Validated type; :identifier triggers instance_identifier
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
Instance Method Details
#bulk=(value) ⇒ Object
When true, wraps read+loop for bulk mode (Array if --bulk yes)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#default=(value) ⇒ Object
Default value when mandatory: false and no argument provided
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#interactive=(value) ⇒ Object
When true, sets ask_missing_mandatory before resolving so interactive prompting is triggered when no CLI args are provided
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#lookup=(value) ⇒ Object
Instance method name for percent-selector resolution (only used when type: :identifier)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#mandatory=(value) ⇒ Object
Default true; optional args must come after all mandatory ones
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |
#name=(value) ⇒ Object
Name used in help and error messages
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aspera/cli/command_spec.rb', line 20 ArgumentSpec = Struct.new( :name, :description, :type, :mandatory, :multiple, :default, :schema, :bulk, :lookup, :allowed, :interactive, keyword_init: true ) do def initialize(**kwargs) kwargs[:mandatory] = true if kwargs[:mandatory].nil? kwargs[:multiple] = false if kwargs[:multiple].nil? kwargs[:bulk] = false if kwargs[:bulk].nil? kwargs[:interactive] = false if kwargs[:interactive].nil? super end end |