aspera-cli 4.29.1 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -4
- data/CHANGELOG.md +119 -0
- data/CONTRIBUTING.md +8 -1
- data/README.md +2 -0
- data/TODO.md +4 -5
- data/bin/asession +2 -2
- data/docs/README.md +616 -86
- data/docs/test-mcp-with-ai.md +4 -0
- data/lib/aspera/agent/base.rb +62 -6
- data/lib/aspera/agent/factory.rb +127 -20
- data/lib/aspera/ascp/data_repository.rb +71 -0
- data/lib/aspera/ascp/installation.rb +16 -11
- data/lib/aspera/ascp/log_analyzer/lines.rb +4 -4
- data/lib/aspera/ascp/log_analyzer/log_file.rb +5 -3
- data/lib/aspera/ascp/log_analyzer/records.rb +11 -6
- data/lib/aspera/ascp/log_analyzer.rb +43 -18
- data/lib/aspera/ascp/log_locations.rb +2 -2
- data/lib/aspera/assert.rb +8 -0
- data/lib/aspera/bundle_registry.rb +528 -0
- data/lib/aspera/cli/argument.rb +110 -0
- data/lib/aspera/cli/bool_value.rb +41 -0
- data/lib/aspera/cli/bootstrapper.rb +31 -24
- data/lib/aspera/cli/command/mount.rb +53 -0
- data/lib/aspera/cli/command/registry.rb +434 -0
- data/lib/aspera/cli/command.rb +95 -0
- data/lib/aspera/cli/command_line.rb +91 -91
- data/lib/aspera/cli/complete.rb +22 -0
- data/lib/aspera/cli/completion_actions.rb +28 -26
- data/lib/aspera/cli/context.rb +29 -6
- data/lib/aspera/cli/error.rb +39 -0
- data/lib/aspera/cli/extended_value.rb +25 -4
- data/lib/aspera/cli/formatter.rb +8 -8
- data/lib/aspera/cli/hints.rb +17 -52
- data/lib/aspera/cli/http.rb +17 -12
- data/lib/aspera/cli/mailer.rb +7 -24
- data/lib/aspera/cli/mcp/tool.rb +10 -2
- data/lib/aspera/cli/option/declarator.rb +80 -0
- data/lib/aspera/cli/option/registry.rb +74 -0
- data/lib/aspera/cli/option/source.rb +38 -0
- data/lib/aspera/cli/option/type.rb +37 -0
- data/lib/aspera/cli/option/value.rb +376 -0
- data/lib/aspera/cli/option.rb +78 -0
- data/lib/aspera/cli/options.schema.yaml +28 -783
- data/lib/aspera/cli/parser.rb +73 -41
- data/lib/aspera/cli/plugins/base.rb +122 -42
- data/lib/aspera/cli/plugins/basic_auth.rb +13 -2
- data/lib/aspera/cli/plugins/config.rb +101 -167
- data/lib/aspera/cli/plugins/factory.rb +139 -43
- data/lib/aspera/cli/plugins/mcp.rb +61 -54
- data/lib/aspera/cli/plugins/oauth.rb +19 -6
- data/lib/aspera/cli/poll.rb +14 -20
- data/lib/aspera/cli/preset_actions.rb +11 -3
- data/lib/aspera/cli/preset_manager.rb +16 -6
- data/lib/aspera/cli/result.rb +2 -2
- data/lib/aspera/cli/runner.rb +71 -99
- data/lib/aspera/cli/secret_finder.rb +1 -1
- data/lib/aspera/cli/security.rb +102 -4
- data/lib/aspera/{preview/terminal.rb → cli/terminal_image.rb} +93 -94
- data/lib/aspera/cli/vault_manager.rb +3 -3
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/cli/wizard.rb +9 -3
- data/lib/aspera/coverage.rb +1 -2
- data/lib/aspera/line_logger.rb +35 -6
- data/lib/aspera/log.rb +3 -2
- data/lib/aspera/oauth/client/base.rb +19 -1
- data/lib/aspera/oauth/client/factory.rb +1 -7
- data/lib/aspera/plugin.schema.yaml +178 -0
- data/lib/aspera/plugins/alee/api.rb +25 -0
- data/lib/aspera/{cli/plugins/alee.rb → plugins/alee/commands.rb} +10 -8
- data/lib/aspera/plugins/alee/plugin.yaml +3 -0
- data/lib/aspera/plugins/aoc/admin_resources.rb +148 -0
- data/lib/aspera/plugins/aoc/api.rb +783 -0
- data/lib/aspera/{cli/plugins/aoc.rb → plugins/aoc/commands.rb} +404 -330
- data/lib/aspera/plugins/aoc/graphql.rb +45 -0
- data/lib/aspera/plugins/aoc/plugin.yaml +31 -0
- data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +15042 -7076
- data/lib/aspera/plugins/aoc/schemas/options.yaml +47 -0
- data/lib/aspera/plugins/ats/api.rb +51 -0
- data/lib/aspera/{cli/plugins/ats.rb → plugins/ats/commands.rb} +33 -33
- data/lib/aspera/plugins/ats/plugin.yaml +6 -0
- data/lib/aspera/plugins/connect/agent.rb +199 -0
- data/lib/aspera/plugins/connect/plugin.yaml +11 -0
- data/lib/aspera/plugins/connect/schemas/agent_options.yaml +6 -0
- data/lib/aspera/{cli/plugins/console.rb → plugins/console/commands.rb} +41 -33
- data/lib/aspera/plugins/console/plugin.yaml +8 -0
- data/lib/aspera/plugins/cos/api.rb +114 -0
- data/lib/aspera/{cli/plugins/cos.rb → plugins/cos/commands.rb} +19 -16
- data/lib/aspera/plugins/cos/plugin.yaml +9 -0
- data/lib/aspera/plugins/cos/schemas/options.yaml +30 -0
- data/lib/aspera/plugins/desktop/agent.rb +165 -0
- data/lib/aspera/plugins/desktop/plugin.yaml +11 -0
- data/lib/aspera/plugins/desktop/schemas/agent_options.yaml +6 -0
- data/lib/aspera/plugins/direct/agent.rb +518 -0
- data/lib/aspera/plugins/direct/plugin.yaml +11 -0
- data/lib/aspera/plugins/direct/schemas/agent_options.yaml +86 -0
- data/lib/aspera/plugins/faspex4/gateway_options.rb +18 -0
- data/lib/aspera/plugins/faspex4/gw_servlet.rb +122 -0
- data/lib/aspera/plugins/faspex4/plugin.yaml +7 -0
- data/lib/aspera/plugins/faspex4/schemas/options.yaml +57 -0
- data/lib/aspera/plugins/faspex5/api.rb +269 -0
- data/lib/aspera/{cli/plugins/faspex5.rb → plugins/faspex5/commands.rb} +152 -114
- data/lib/aspera/plugins/faspex5/faspex4_post_proc_servlet.rb +241 -0
- data/lib/aspera/plugins/faspex5/plugin.yaml +14 -0
- data/lib/aspera/{schema → plugins/faspex5/schemas}/IBM Aspera Faspex API-5.0-enhanced.yaml +279 -76
- data/lib/aspera/plugins/faspex5/schemas/options.yaml +87 -0
- data/lib/aspera/{cli/plugins/faspio.rb → plugins/faspio/commands.rb} +11 -7
- data/lib/aspera/plugins/faspio/plugin.yaml +8 -0
- data/lib/aspera/{schema → plugins/faspio/schemas}/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +4 -2
- data/lib/aspera/plugins/httpgw/agent.rb +126 -0
- data/lib/aspera/plugins/httpgw/api.rb +411 -0
- data/lib/aspera/{cli/plugins/httpgw.rb → plugins/httpgw/commands.rb} +9 -9
- data/lib/aspera/plugins/httpgw/plugin.yaml +12 -0
- data/lib/aspera/plugins/httpgw/schemas/agent_options.yaml +24 -0
- data/lib/aspera/plugins/node/agent.rb +184 -0
- data/lib/aspera/plugins/node/api.rb +699 -0
- data/lib/aspera/{cli/plugins/node.rb → plugins/node/commands.rb} +166 -141
- data/lib/aspera/plugins/node/emulator.rb +774 -0
- data/lib/aspera/plugins/node/plugin.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/agent_options.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/options.yaml +190 -0
- data/lib/aspera/{cli/plugins/orchestrator.rb → plugins/orchestrator/commands.rb} +139 -110
- data/lib/aspera/plugins/orchestrator/plugin.yaml +34 -0
- data/lib/aspera/{schema → plugins/orchestrator/schemas}/IBM Aspera Orchestrator API-v1-enhanced.yaml +486 -16
- data/lib/aspera/plugins/orchestrator/schemas/options.yaml +143 -0
- data/lib/aspera/plugins/orchestrator/workflow_checker.rb +692 -0
- data/lib/aspera/{cli/plugins/preview.rb → plugins/preview/commands.rb} +53 -51
- data/lib/aspera/plugins/preview/file_types.rb +121 -0
- data/lib/aspera/plugins/preview/generator.rb +350 -0
- data/lib/aspera/plugins/preview/plugin.yaml +12 -0
- data/lib/aspera/{preview/options.schema.yaml → plugins/preview/schemas/options.yaml} +1 -1
- data/lib/aspera/plugins/preview/utils.rb +213 -0
- data/lib/aspera/plugins/server/ascmd.rb +374 -0
- data/lib/aspera/{cli/plugins/server.rb → plugins/server/commands.rb} +48 -32
- data/lib/aspera/plugins/server/plugin.yaml +9 -0
- data/lib/aspera/plugins/server/schemas/options.yaml +30 -0
- data/lib/aspera/{cli/plugins/shares.rb → plugins/shares/commands.rb} +29 -21
- data/lib/aspera/plugins/shares/plugin.yaml +10 -0
- data/lib/aspera/plugins/shares/shares_web.rb +97 -0
- data/lib/aspera/plugins/transferd/agent.rb +258 -0
- data/lib/aspera/plugins/transferd/api.rb +180 -0
- data/lib/aspera/plugins/transferd/client.rb +67 -0
- data/lib/aspera/{cli/plugins/transferd.rb → plugins/transferd/commands.rb} +43 -42
- data/lib/aspera/plugins/transferd/config_commands.rb +38 -0
- data/lib/aspera/plugins/transferd/plugin.yaml +27 -0
- data/lib/aspera/plugins/transferd/product.rb +146 -0
- data/lib/aspera/plugins/transferd/schemas/agent_options.yaml +31 -0
- data/lib/aspera/plugins/transferd/schemas/options.yaml +80 -0
- data/lib/aspera/plugins/transferd/service.rb +617 -0
- data/lib/aspera/plugins/xfer/ascp_actions.rb +131 -0
- data/lib/aspera/plugins/xfer/ascp_logs_actions.rb +198 -0
- data/lib/aspera/plugins/xfer/async_transfer_store.rb +131 -0
- data/lib/aspera/plugins/xfer/config_commands.rb +119 -0
- data/lib/aspera/plugins/xfer/helper.rb +19 -0
- data/lib/aspera/plugins/xfer/plugin.yaml +42 -0
- data/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml +26 -0
- data/lib/aspera/plugins/xfer/schemas/options.yaml +125 -0
- data/lib/aspera/plugins/xfer/sync_actions.rb +253 -0
- data/lib/aspera/plugins/xfer/transfer_actions.rb +176 -0
- data/lib/aspera/plugins/xfer/transfer_agent.rb +505 -0
- data/lib/aspera/products/cli_v3.rb +34 -0
- data/lib/aspera/products/connect.rb +1 -1
- data/lib/aspera/products/drive.rb +29 -0
- data/lib/aspera/products/hsts.rb +34 -0
- data/lib/aspera/products/transferd.rb +25 -3
- data/lib/aspera/products.rb +54 -0
- data/lib/aspera/prompt.rb +184 -0
- data/lib/aspera/proxy_auto_config.rb +3 -3
- data/lib/aspera/rest/aspera_errors.rb +4 -38
- data/lib/aspera/rest/error_analyzer.rb +6 -2
- data/lib/aspera/rest/list.rb +4 -5
- data/lib/aspera/schema/reader.rb +15 -0
- data/lib/aspera/schema/registry.rb +239 -45
- data/lib/aspera/schema/validator.rb +63 -17
- data/lib/aspera/sealed_hash.rb +4 -0
- data/lib/aspera/secret/hider.rb +159 -24
- data/lib/aspera/secret/reference.rb +8 -0
- data/lib/aspera/secret/resolver.rb +8 -4
- data/lib/aspera/secret/store/base.rb +10 -9
- data/lib/aspera/secret/store/encrypted_hash.rb +6 -6
- data/lib/aspera/secret/store/hashicorp_vault.rb +3 -3
- data/lib/aspera/secret/store/keeper.rb +2 -2
- data/lib/aspera/secret/store/macos_security.rb +2 -3
- data/lib/aspera/secret/store/one_password_api.rb +2 -2
- data/lib/aspera/secret/store/one_password_cli.rb +3 -3
- data/lib/aspera/secret/store/secret_service.rb +2 -2
- data/lib/aspera/ssl.rb +3 -3
- data/lib/aspera/standard_input.rb +20 -0
- data/lib/aspera/{schema → sync}/async_tables.yaml +1 -1
- data/lib/aspera/sync/database.rb +7 -0
- data/lib/aspera/sync/log_parser.rb +138 -0
- data/lib/aspera/sync/operations.rb +59 -34
- data/lib/aspera/transfer/command_line_builder.rb +248 -0
- data/lib/aspera/transfer/command_line_converter.rb +37 -0
- data/lib/aspera/transfer/faux_file.rb +2 -2
- data/lib/aspera/transfer/parameters.rb +9 -10
- data/lib/aspera/transfer/spec.rb +28 -1
- data/lib/aspera/transfer/spec.schema.yaml +30 -5
- data/lib/aspera/units/decimal.rb +1 -1
- data/lib/aspera/units/timestamp.rb +84 -0
- data/lib/aspera/uri_reader.rb +2 -2
- data/lib/aspera/web_auth/paste.rb +2 -2
- data/lib/aspera/web_server_simple.rb +10 -4
- data.tar.gz.sig +0 -0
- metadata +137 -80
- metadata.gz.sig +0 -0
- data/lib/aspera/agent/connect.rb +0 -188
- data/lib/aspera/agent/desktop.rb +0 -154
- data/lib/aspera/agent/direct.rb +0 -496
- data/lib/aspera/agent/httpgw.rb +0 -100
- data/lib/aspera/agent/node.rb +0 -166
- data/lib/aspera/agent/transferd.rb +0 -341
- data/lib/aspera/api/alee.rb +0 -19
- data/lib/aspera/api/aoc.rb +0 -776
- data/lib/aspera/api/ats.rb +0 -49
- data/lib/aspera/api/cos_node.rb +0 -107
- data/lib/aspera/api/faspex.rb +0 -258
- data/lib/aspera/api/httpgw.rb +0 -409
- data/lib/aspera/api/node.rb +0 -684
- data/lib/aspera/ascmd.rb +0 -248
- data/lib/aspera/cli/ascp_actions.rb +0 -113
- data/lib/aspera/cli/ascp_logs_actions.rb +0 -188
- data/lib/aspera/cli/async_transfer_store.rb +0 -129
- data/lib/aspera/cli/command_registry.rb +0 -371
- data/lib/aspera/cli/command_spec.rb +0 -273
- data/lib/aspera/cli/option_declarator.rb +0 -74
- data/lib/aspera/cli/option_registry.rb +0 -72
- data/lib/aspera/cli/option_types.rb +0 -120
- data/lib/aspera/cli/option_value.rb +0 -345
- data/lib/aspera/cli/prompt.rb +0 -186
- data/lib/aspera/cli/sync_actions.rb +0 -181
- data/lib/aspera/cli/transfer_actions.rb +0 -98
- data/lib/aspera/cli/transfer_agent.rb +0 -348
- data/lib/aspera/command_line_builder.rb +0 -244
- data/lib/aspera/command_line_converter.rb +0 -35
- data/lib/aspera/data_repository.rb +0 -69
- data/lib/aspera/faspex_gw.rb +0 -172
- data/lib/aspera/faspex_postproc.rb +0 -237
- data/lib/aspera/graphql.rb +0 -41
- data/lib/aspera/node_emulator.rb +0 -758
- data/lib/aspera/oauth/client/shares_web.rb +0 -94
- data/lib/aspera/orchestrator_workflow_checker.rb +0 -688
- data/lib/aspera/preview/file_types.rb +0 -119
- data/lib/aspera/preview/generator.rb +0 -345
- data/lib/aspera/preview/utils.rb +0 -211
- data/lib/aspera/products/other.rb +0 -92
- data/lib/aspera/products/transferd_service.rb +0 -610
- /data/lib/aspera/{data → ascp/data}/1 +0 -0
- /data/lib/aspera/{data → ascp/data}/2 +0 -0
- /data/lib/aspera/{data → ascp/data}/3 +0 -0
- /data/lib/aspera/{data → ascp/data}/4 +0 -0
- /data/lib/aspera/{data → ascp/data}/5 +0 -0
- /data/lib/aspera/{data → ascp/data}/6 +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_account.graphql +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_usage.graphql +0 -0
- /data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/console/schemas}/IBM Aspera Console-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/node/schemas}/IBM Aspera Node API-4.4.6.yaml +0 -0
- /data/lib/aspera/{preview → plugins/preview}/image_error.png +0 -0
- /data/lib/aspera/{preview → plugins/preview}/video_error.png +0 -0
- /data/lib/aspera/{schema → plugins/shares/schemas}/IBM_Aspera_Shares.yaml +0 -0
- /data/lib/{transferd_pb.rb → aspera/plugins/transferd/grpc/transferd_pb.rb} +0 -0
- /data/lib/{transferd_services_pb.rb → aspera/plugins/transferd/grpc/transferd_services_pb.rb} +0 -0
- /data/lib/aspera/{schema → plugins/transferd/schemas}/transferd-config.schema.json +0 -0
|
@@ -8,11 +8,15 @@ require_relative '../parser'
|
|
|
8
8
|
require_relative '../../assert'
|
|
9
9
|
require_relative '../result'
|
|
10
10
|
require_relative '../poll'
|
|
11
|
-
require_relative '../
|
|
12
|
-
require_relative '../
|
|
11
|
+
require_relative '../command/registry'
|
|
12
|
+
require_relative '../option/declarator'
|
|
13
|
+
require_relative '../security'
|
|
13
14
|
require_relative '../special_values'
|
|
15
|
+
require_relative '../../bundle_registry'
|
|
16
|
+
require_relative '../../log'
|
|
14
17
|
require_relative '../../rest/list'
|
|
15
18
|
require_relative '../../schema/registry'
|
|
19
|
+
require_relative '../../string_ext'
|
|
16
20
|
|
|
17
21
|
module Aspera
|
|
18
22
|
module Cli
|
|
@@ -30,7 +34,7 @@ module Aspera
|
|
|
30
34
|
ALL = (GLOBAL + INSTANCE).freeze
|
|
31
35
|
end
|
|
32
36
|
class << self
|
|
33
|
-
include
|
|
37
|
+
include Option::Declarator
|
|
34
38
|
|
|
35
39
|
# Option sources added with `use_options`, with their `on_set` target.
|
|
36
40
|
# @return [Hash{Class, Module => Proc, nil}]
|
|
@@ -38,7 +42,7 @@ module Aspera
|
|
|
38
42
|
@used_option_sources ||= {}
|
|
39
43
|
end
|
|
40
44
|
|
|
41
|
-
# Include options from another plugin or
|
|
45
|
+
# Include options from another plugin or Option::Declarator module.
|
|
42
46
|
# @param source [Class, Module]
|
|
43
47
|
# @param target [Proc, nil] Executed on the plugin instance, returns the object for Symbol and Proc `on_set` callbacks
|
|
44
48
|
# of `source` (e.g. `-> { http_config }`); nil: the plugin instance
|
|
@@ -47,18 +51,20 @@ module Aspera
|
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
# Per-class DSL registry (not inherited: each subclass gets its own instance).
|
|
50
|
-
# @return [
|
|
54
|
+
# @return [Command::Registry]
|
|
51
55
|
def command_registry
|
|
52
|
-
@command_registry ||=
|
|
56
|
+
@command_registry ||= Command::Registry.new
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
# DSL class method: register a command in this plugin's registry.
|
|
56
60
|
# Inherits parent from the enclosing commands_under block when parent: is omitted.
|
|
57
|
-
# @param id
|
|
58
|
-
# @param
|
|
59
|
-
|
|
61
|
+
# @param id [Symbol]
|
|
62
|
+
# @param before [Symbol, nil] Command of the same parent before which this one is placed (e.g. by a mounted module), `nil`: after the others
|
|
63
|
+
# @param kwargs [Hash] forwarded to [Command]
|
|
64
|
+
def command(id, before: nil, **kwargs)
|
|
60
65
|
kwargs[:parent] = @current_parent if kwargs[:parent].nil? && @current_parent
|
|
61
|
-
|
|
66
|
+
kwargs[:security] = mounted_level(kwargs[:security])
|
|
67
|
+
command_registry.register(Command.new(id: id, **kwargs), before: before)
|
|
62
68
|
end
|
|
63
69
|
|
|
64
70
|
# Words displayed with specific case in descriptions
|
|
@@ -94,7 +100,7 @@ module Aspera
|
|
|
94
100
|
|
|
95
101
|
# DSL class method: declare CRUD commands for a REST entity.
|
|
96
102
|
#
|
|
97
|
-
# For each verb in operations:, registers one
|
|
103
|
+
# For each verb in operations:, registers one Command with:
|
|
98
104
|
# - description: operation_description(verb, name)
|
|
99
105
|
# - arguments: [{name: id_name, type: :identifier, lookup: lookup}] for instance verbs
|
|
100
106
|
# (:show, :modify, :delete) when not a singleton; none for global verbs
|
|
@@ -171,11 +177,11 @@ module Aspera
|
|
|
171
177
|
end
|
|
172
178
|
|
|
173
179
|
# DSL class method: define an instance method whose name is derived from a path array.
|
|
174
|
-
# Equivalent to: define_method(
|
|
180
|
+
# Equivalent to: define_method(Command.action_method(path), &block)
|
|
175
181
|
# @param path [Array<Symbol>] command path segments, e.g. [:admin, :user, :list]
|
|
176
182
|
# @yieldparam [Hash] keyword context forwarded from dispatch
|
|
177
183
|
def define_action_method(path, &block)
|
|
178
|
-
define_method(
|
|
184
|
+
define_method(Command.action_method(path), &block)
|
|
179
185
|
end
|
|
180
186
|
|
|
181
187
|
# DSL class method: scope block that sets a default parent for nested command() calls.
|
|
@@ -208,26 +214,28 @@ module Aspera
|
|
|
208
214
|
@current_parent = previous
|
|
209
215
|
end
|
|
210
216
|
|
|
211
|
-
# Options of this plugin class (`option` DSL, see
|
|
212
|
-
# Metadata is stored as an
|
|
217
|
+
# Options of this plugin class (`option` DSL, see Option::Declarator).
|
|
218
|
+
# Metadata is stored as an Option at class-load time; the actual
|
|
213
219
|
# options.declare call happens in Base#initialize once the instance exists.
|
|
214
|
-
# @return [Hash{Symbol =>
|
|
220
|
+
# @return [Hash{Symbol => Option}]
|
|
215
221
|
def option_specs
|
|
216
222
|
command_registry.option_specs
|
|
217
223
|
end
|
|
218
224
|
|
|
219
|
-
# Store an
|
|
225
|
+
# Store an Option in the command registry.
|
|
220
226
|
# Raises ArgumentError at class-load time if the same option name is already
|
|
221
227
|
# declared by any ancestor class, preventing silent shadowing.
|
|
222
|
-
# @param spec
|
|
223
|
-
|
|
228
|
+
# @param spec [Option]
|
|
229
|
+
# @param before [Symbol, nil] Name of an option of this class to place it before (see `Command::Registry#register_option`)
|
|
230
|
+
def register_option_spec(spec, before: nil)
|
|
224
231
|
ancestor_owner = ancestors.drop(1).find do |klass|
|
|
225
232
|
klass.is_a?(Class) && klass <= Base &&
|
|
226
233
|
klass.instance_variable_defined?(:@command_registry) &&
|
|
227
|
-
klass.command_registry.
|
|
234
|
+
klass.command_registry.option_registered?(spec.name)
|
|
228
235
|
end
|
|
229
236
|
raise ArgumentError, "#{self}: option :#{spec.name} already declared in ancestor #{ancestor_owner}" if ancestor_owner
|
|
230
|
-
|
|
237
|
+
spec.security = mounted_level(spec.security)
|
|
238
|
+
command_registry.register_option(spec, before: before)
|
|
231
239
|
end
|
|
232
240
|
|
|
233
241
|
# Classes and modules whose options apply to this plugin:
|
|
@@ -258,14 +266,50 @@ module Aspera
|
|
|
258
266
|
options.parse_options! if parse
|
|
259
267
|
end
|
|
260
268
|
|
|
269
|
+
# Name of the plugin: its top level command, set by `Factory` when it loads the class: name of the file (single file) or of the bundle.
|
|
270
|
+
# Default (class not loaded by `Factory`, e.g. `Config`): from the class name `Aspera::Cli::Plugins::<Name>` or `Aspera::Plugins::<Name>::Commands`.
|
|
271
|
+
# @return [String]
|
|
272
|
+
def plugin_name
|
|
273
|
+
@plugin_name || (name[/\AAspera::Plugins::(\w+)::Commands\z/, 1] || name.split('::').last).capital_to_snake
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# @!attribute [w] plugin_name
|
|
277
|
+
# @param value [String] Name of the plugin, set by `Factory`
|
|
278
|
+
attr_writer :plugin_name
|
|
279
|
+
|
|
280
|
+
# Include the modules that bundles mount on this plugin (manifest `mounts`), each once, by name of bundle, then in the order of the manifest.
|
|
281
|
+
# The `included` hook of a module declares its commands and options in this class, as an `include` of the module at this place of the class body would.
|
|
282
|
+
# Called by `Factory` when it loads the class: mounted commands come after the ones of the class body; a class body may call it to place them.
|
|
283
|
+
# The module of a bundle whose source is refused at the current security level is not loaded; the commands and options declared by a module
|
|
284
|
+
# get the security level of its source, if more restrictive.
|
|
285
|
+
# @param registry [BundleRegistry] Registry of the bundles
|
|
286
|
+
# @return [nil]
|
|
287
|
+
def include_mounts(registry = BundleRegistry.instance)
|
|
288
|
+
@included_mounts ||= []
|
|
289
|
+
registry.mounts(plugin_name.to_sym).each do |mount|
|
|
290
|
+
next if @included_mounts.include?(mount) || !registry.allowed?(mount.bundle)
|
|
291
|
+
@included_mounts.push(mount)
|
|
292
|
+
mounted = registry.load_entry(mount)
|
|
293
|
+
Aspera.assert(mounted.instance_of?(Module)) { "plugin #{mount.bundle}: #{mount.constant} is not a module" }
|
|
294
|
+
@mount_security = registry[mount.bundle].security
|
|
295
|
+
include(mounted)
|
|
296
|
+
rescue BundleRegistry::Unavailable, AssertError, NameError, ScriptError, ArgumentError => e
|
|
297
|
+
# A broken module (wrong constant, syntax error, failing hook) is skipped as an unavailable bundle: the target plugin still works
|
|
298
|
+
Log.log.warn { "Commands of plugin #{mount.bundle} are not added to #{plugin_name}: #{e.message}" }
|
|
299
|
+
ensure
|
|
300
|
+
@mount_security = nil
|
|
301
|
+
end
|
|
302
|
+
nil
|
|
303
|
+
end
|
|
304
|
+
|
|
261
305
|
# DSL class method: declare the human-readable application name shown in wizards.
|
|
262
306
|
# When called with an argument, sets the name. When called with no argument, returns it.
|
|
263
|
-
# Falls back to the
|
|
307
|
+
# Falls back to the plugin name in CamelCase if never set.
|
|
264
308
|
# @param name [String, nil]
|
|
265
309
|
# @return [String]
|
|
266
310
|
def application_name(name = nil)
|
|
267
311
|
@application_name = name unless name.nil?
|
|
268
|
-
@application_name ||
|
|
312
|
+
@application_name || plugin_name.snake_to_capital
|
|
269
313
|
end
|
|
270
314
|
|
|
271
315
|
# Build a filter lambda from a match expression (String glob, Regexp, Proc, or nil).
|
|
@@ -280,6 +324,16 @@ module Aspera
|
|
|
280
324
|
else Aspera.error_unexpected_value(match_expression.class.name, type: ParameterError)
|
|
281
325
|
end
|
|
282
326
|
end
|
|
327
|
+
|
|
328
|
+
private
|
|
329
|
+
|
|
330
|
+
# @param level [Symbol, nil] Security level of a command or option declared in this class
|
|
331
|
+
# @return [Symbol, nil] The most restrictive of this level and the one of the source of the module being mounted (see `include_mounts`)
|
|
332
|
+
def mounted_level(level)
|
|
333
|
+
return level if @mount_security.nil?
|
|
334
|
+
return @mount_security if level.nil?
|
|
335
|
+
[level, @mount_security].min_by { |item| Security::LEVELS.index(item) }
|
|
336
|
+
end
|
|
283
337
|
end
|
|
284
338
|
|
|
285
339
|
# Shared positional argument for commands that accept an optional file name filter.
|
|
@@ -288,8 +342,8 @@ module Aspera
|
|
|
288
342
|
FILTER_ARGS = [{name: :filter, type: [String, Regexp, Proc], description: 'File name filter: String (glob), Regexp, or Proc', mandatory: false, default: nil}].freeze
|
|
289
343
|
|
|
290
344
|
option :query, description: 'Additional filter for for some commands (list/delete)', allowed: [Hash, Array, NilClass]
|
|
291
|
-
option :bulk, description: 'Bulk operation (only some)', allowed: Type::BOOLEAN, default: false
|
|
292
|
-
option :bfail, description: 'Bulk operation error handling', allowed: Type::BOOLEAN, default: true
|
|
345
|
+
option :bulk, description: 'Bulk operation (only some)', allowed: Option::Type::BOOLEAN, default: false
|
|
346
|
+
option :bfail, description: 'Bulk operation error handling', allowed: Option::Type::BOOLEAN, default: true
|
|
293
347
|
option :poll, description: 'Repeat a read-only command (dot-notation: interval, max, timeout, until, show, errors)', schema: Schema::Registry::POLL_OPTIONS
|
|
294
348
|
|
|
295
349
|
def initialize(context:)
|
|
@@ -299,9 +353,9 @@ module Aspera
|
|
|
299
353
|
# Switch to the plugin-specific options group so that all options declared
|
|
300
354
|
# below (DSL-registered and imperative) appear under the plugin section in
|
|
301
355
|
# --help output, separate from the global options.
|
|
302
|
-
options.group(self.class.
|
|
356
|
+
options.group(self.class.plugin_name) if @context.man_header
|
|
303
357
|
# Auto-declare all options registered via the DSL `option` class method,
|
|
304
|
-
# including those of
|
|
358
|
+
# including those of modules that give theirs when included (e.g. Oauth, BasicAuth) and `use_options` sources.
|
|
305
359
|
self.class.declare_options(options, target: self)
|
|
306
360
|
end
|
|
307
361
|
|
|
@@ -313,7 +367,8 @@ module Aspera
|
|
|
313
367
|
|
|
314
368
|
# @return [Aspera::Cli::Parser]
|
|
315
369
|
def options; @context.options; end
|
|
316
|
-
#
|
|
370
|
+
# Plugins of bundles use `Aspera::Plugins::Xfer::Helper#transfer` (bundle `xfer`)
|
|
371
|
+
# @return [Object] Service `transfer` of the context (`Aspera::Plugins::Xfer::TransferAgent`)
|
|
317
372
|
def transfer; @context.transfer; end
|
|
318
373
|
# @return [Aspera::Cli::Plugins::Config]
|
|
319
374
|
def config; @context.config; end
|
|
@@ -358,7 +413,7 @@ module Aspera
|
|
|
358
413
|
Security.instance.check_level(spec.security, "command #{current_path.join(' ')}") if spec
|
|
359
414
|
# Before anything is executed (setup, arguments, action)
|
|
360
415
|
poll = poll_result(current_path, spec) if is_leaf
|
|
361
|
-
# Phase A - for intermediate nodes only: resolve all
|
|
416
|
+
# Phase A - for intermediate nodes only: resolve all Argument declared on this node
|
|
362
417
|
# before dispatching to children (leaf nodes resolve their arguments inside execute_leaf).
|
|
363
418
|
ctx = resolve_arguments(spec.arguments, ctx) if !is_leaf && spec&.arguments
|
|
364
419
|
ctx = ctx.merge(send(spec.setup, **ctx)) if spec&.setup
|
|
@@ -375,7 +430,7 @@ module Aspera
|
|
|
375
430
|
# Phase B, leaf branch: execute a spec that is already a leaf (no children).
|
|
376
431
|
# Intercepts --help before calling execute_leaf.
|
|
377
432
|
# @param current_path [Array<Symbol>]
|
|
378
|
-
# @param spec [
|
|
433
|
+
# @param spec [Command]
|
|
379
434
|
# @param ctx [Hash]
|
|
380
435
|
# @param poll [Result::Poll, nil] With option `poll`: result that executes the action when displayed
|
|
381
436
|
# @return [Object]
|
|
@@ -389,13 +444,13 @@ module Aspera
|
|
|
389
444
|
|
|
390
445
|
# With option `poll`, check that the command is read-only, and the parameters of `poll`
|
|
391
446
|
# @param current_path [Array<Symbol>] path of the leaf command
|
|
392
|
-
# @param spec [
|
|
447
|
+
# @param spec [Command] leaf command
|
|
393
448
|
# @return [Result::Poll, nil] `nil` if option `poll` is not set
|
|
394
449
|
# @raise [Cli::BadArgument] if the command is not read-only, or a parameter is invalid
|
|
395
450
|
def poll_result(current_path, spec)
|
|
396
451
|
parameters = options.get_option(:poll)
|
|
397
452
|
return if parameters.nil? || parameters.empty?
|
|
398
|
-
command = [self.class.
|
|
453
|
+
command = [self.class.plugin_name, *current_path].join(' ')
|
|
399
454
|
Aspera.assert(spec.read_only?, type: Cli::BadArgument) do
|
|
400
455
|
"Option poll: refused on `#{command}`: only a read-only command can be repeated (e.g. list, show, status)"
|
|
401
456
|
end
|
|
@@ -414,7 +469,7 @@ module Aspera
|
|
|
414
469
|
# 2. After get_next_command when no further args remain: raises HelpRequest scoped
|
|
415
470
|
# to the consumed command (e.g. `aoc files find -h`).
|
|
416
471
|
# @param current_path [Array<Symbol>]
|
|
417
|
-
# @param registry [
|
|
472
|
+
# @param registry [Command::Registry]
|
|
418
473
|
# @param ctx [Hash]
|
|
419
474
|
# @return [Object]
|
|
420
475
|
def dispatch_child(current_path, registry, ctx)
|
|
@@ -458,7 +513,7 @@ module Aspera
|
|
|
458
513
|
# Setups of the mount point `at` and of its ancestors in the target are not executed:
|
|
459
514
|
# the seed ctx returned by the host's `instance` method replaces them.
|
|
460
515
|
# The mount's own arguments (if any) are read first, and passed to `instance` in ctx.
|
|
461
|
-
# @param mount [
|
|
516
|
+
# @param mount [Command::Mount]
|
|
462
517
|
# @param command [Symbol] mounted child id, already consumed
|
|
463
518
|
# @param ctx [Hash] host context, passed to the `instance` method
|
|
464
519
|
# @return [Object]
|
|
@@ -479,11 +534,11 @@ module Aspera
|
|
|
479
534
|
self.class.instance_variable_set(:@registry_validated, true)
|
|
480
535
|
end
|
|
481
536
|
|
|
482
|
-
# Resolve the action for a leaf
|
|
537
|
+
# Resolve the action for a leaf Command.
|
|
483
538
|
# Returns spec.action (Symbol or Proc) if explicitly set; otherwise derives a Symbol
|
|
484
539
|
# from the full path as :action_<path_segment_1>_<path_segment_2>_...
|
|
485
540
|
# (e.g. [:access_key, :list] -> :action_access_key_list).
|
|
486
|
-
# @param spec [
|
|
541
|
+
# @param spec [Command]
|
|
487
542
|
# @return [Symbol, Proc]
|
|
488
543
|
def action_for(spec)
|
|
489
544
|
spec.action || spec.action_method_name
|
|
@@ -504,10 +559,10 @@ module Aspera
|
|
|
504
559
|
end
|
|
505
560
|
end
|
|
506
561
|
|
|
507
|
-
# Execute a leaf
|
|
562
|
+
# Execute a leaf Command: resolve arguments and call action.
|
|
508
563
|
# Arguments already present in `ctx` (e.g. provided by a caller or a mount seed) are skipped:
|
|
509
564
|
# they are not read again from the command line.
|
|
510
|
-
# @param spec [
|
|
565
|
+
# @param spec [Command] a leaf node (no children)
|
|
511
566
|
# @param ctx [Hash] accumulated context (pre-resolved keys are not re-consumed)
|
|
512
567
|
# @param poll [Result::Poll, nil] With option `poll`: the action is executed when this result is displayed
|
|
513
568
|
# @return [Object]
|
|
@@ -527,7 +582,7 @@ module Aspera
|
|
|
527
582
|
# If the next CLI argument is that same value, or `ALL`, it is skipped, so that it is not mistaken for a later argument
|
|
528
583
|
# (e.g. `faspex5 packages receive ALL` with a public link to a package).
|
|
529
584
|
# For type: :identifier, the percent-selector lookup receives the ctx accumulated so far.
|
|
530
|
-
# @param arg_specs [Array<
|
|
585
|
+
# @param arg_specs [Array<Argument>]
|
|
531
586
|
# @param ctx [Hash] accumulated context
|
|
532
587
|
# @return [Hash] ctx merged with the resolved arguments
|
|
533
588
|
def resolve_arguments(arg_specs, ctx)
|
|
@@ -546,16 +601,41 @@ module Aspera
|
|
|
546
601
|
when Symbol then ->(f, v) { send(lookup_cb, f, v, **current) }
|
|
547
602
|
else ->(f, v) { instance_exec(f, v, **current, &lookup_cb) }
|
|
548
603
|
end
|
|
549
|
-
ctx = ctx.merge(arg_spec.name => resolve_argument(arg_spec, &block))
|
|
604
|
+
ctx = ctx.merge(arg_spec.name => check_argument_access(arg_spec, resolve_argument(arg_spec, &block)))
|
|
550
605
|
end
|
|
551
606
|
ctx
|
|
552
607
|
end
|
|
553
608
|
|
|
609
|
+
# A local path given as an argument (`access: :read` or `:write`) is checked against the security level when it is read,
|
|
610
|
+
# and replaced by its real path, so that the action receives a checked path (see `Cli::Security`).
|
|
611
|
+
# For an argument with `stdin: true`, `-` is not a local path: it is `@stdin:stream`, the standard input read by the command (`StandardInput`),
|
|
612
|
+
# refused where `@stdin:` is disabled (MCP server mode). Elsewhere, `-` is a path, checked as any other.
|
|
613
|
+
# @param arg_spec [Argument] declaration of the argument
|
|
614
|
+
# @param value [Object] resolved value (a path, a `StandardInput`, an Array of those, or nil)
|
|
615
|
+
# @return [Object] the value, with each path checked and resolved, and `-` replaced by a `StandardInput`
|
|
616
|
+
def check_argument_access(arg_spec, value)
|
|
617
|
+
return value if value.nil?
|
|
618
|
+
security = Security.instance
|
|
619
|
+
resolver =
|
|
620
|
+
case arg_spec.access
|
|
621
|
+
when nil, :none then return value
|
|
622
|
+
when :read then security.method(:readable_path)
|
|
623
|
+
when :write then security.method(:writable_path)
|
|
624
|
+
else Aspera.error_unexpected_value(arg_spec.access) { "access of argument #{arg_spec.name}" }
|
|
625
|
+
end
|
|
626
|
+
mapper = lambda do |one|
|
|
627
|
+
next one unless one.is_a?(String)
|
|
628
|
+
next resolver.call(one) unless arg_spec.stdin && one.eql?(StandardInput::NAME)
|
|
629
|
+
ExtendedValue.instance.evaluate('@stdin:stream', context: "argument #{arg_spec.name} (#{StandardInput::NAME})", allowed: arg_spec.type)
|
|
630
|
+
end
|
|
631
|
+
value.is_a?(Array) ? value.map(&mapper) : mapper.call(value)
|
|
632
|
+
end
|
|
633
|
+
|
|
554
634
|
# Resolve a single positional argument from the CLI argument stream.
|
|
555
635
|
# When arg_spec.bulk is true, always returns an Array (normalized to [value] when non-bulk).
|
|
556
636
|
# Only such arguments are read as a list with `--bulk=yes`: others (e.g. the id of a parent node) are single values.
|
|
557
637
|
# For type: :identifier, an optional block provides the percent-selector lookup.
|
|
558
|
-
# @param arg_spec [
|
|
638
|
+
# @param arg_spec [Argument]
|
|
559
639
|
# @yieldparam field [String] field name from a percent-selector (%field:value)
|
|
560
640
|
# @yieldparam value [String] value from a percent-selector
|
|
561
641
|
# @yieldreturn [String] resolved identifier
|
|
@@ -660,7 +740,7 @@ module Aspera
|
|
|
660
740
|
# --- Per-verb entity action methods ---
|
|
661
741
|
# Each method handles exactly one CRUD verb.
|
|
662
742
|
# The resource id (when needed) is received as `id:` from ctx — it must be
|
|
663
|
-
# resolved upstream via an
|
|
743
|
+
# resolved upstream via an Argument(type: :identifier) on the command,
|
|
664
744
|
# NOT read from the CLI queue inside the method.
|
|
665
745
|
|
|
666
746
|
# List all instances of an entity.
|
|
@@ -9,8 +9,19 @@ require_relative 'base'
|
|
|
9
9
|
module Aspera
|
|
10
10
|
module Cli
|
|
11
11
|
module Plugins
|
|
12
|
-
#
|
|
13
|
-
class
|
|
12
|
+
# Module for plugins of applications supporting basic authentication: `include Cli::Plugins::BasicAuth` in a plugin class.
|
|
13
|
+
# Its `included` hook gives the options of the module to the plugin class (`use_options`); `Oauth` includes this module and adds the options itself.
|
|
14
|
+
module BasicAuth
|
|
15
|
+
extend Option::Declarator
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
# @param base [Class] Plugin class that includes the module
|
|
19
|
+
def included(base)
|
|
20
|
+
super
|
|
21
|
+
base.use_options(self) if base.is_a?(Class)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
14
25
|
option :url, description: 'URL of application, e.g. https://app.example.com/aspera/app'
|
|
15
26
|
option :username, description: "User's identifier"
|
|
16
27
|
option :password, description: "User's password"
|