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
data/lib/aspera/cli/prompt.rb
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
6
|
-
require_relative '../assert'
|
|
7
|
-
require_relative '../environment'
|
|
8
|
-
require_relative '../rainbow'
|
|
9
|
-
require 'io/console'
|
|
10
|
-
require 'unicode/display_width'
|
|
11
|
-
|
|
12
|
-
using Rainbow
|
|
13
|
-
|
|
14
|
-
module Aspera
|
|
15
|
-
module Cli
|
|
16
|
-
# Console input
|
|
17
|
-
module Prompt
|
|
18
|
-
extend self
|
|
19
|
-
|
|
20
|
-
# Prompt user for console input
|
|
21
|
-
# The prompt is displayed on `stderr`, like for sensitive input, so that `stdout` contains only results.
|
|
22
|
-
# @param prompt [String] prompt string to display
|
|
23
|
-
# @param sensitive [Boolean] whether to hide typed input
|
|
24
|
-
# @param validate [Proc, nil] Called with the input: raises `ParameterError` (with the reason) if the input is not valid. Its result is not used.
|
|
25
|
-
# On a terminal, hidden input shows whether it is valid, and if not, the error is displayed and the input is asked again.
|
|
26
|
-
# @return [String] user input stripped of trailing newline
|
|
27
|
-
def prompt_user_input(prompt, sensitive: false, validate: nil)
|
|
28
|
-
loop do
|
|
29
|
-
line = read_input(prompt, sensitive, validate)
|
|
30
|
-
begin
|
|
31
|
-
validate&.call(line)
|
|
32
|
-
return line
|
|
33
|
-
rescue ParameterError => e
|
|
34
|
-
# not a terminal: nobody to ask again
|
|
35
|
-
raise unless $stdin.tty?
|
|
36
|
-
$stderr.puts("#{e.message}. Try again, or Ctrl-C to stop.".red) # rubocop:disable Style/StderrPuts
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Prompt user for input in a list of symbols
|
|
42
|
-
# @param prompt [String] prompt to display
|
|
43
|
-
# @param sym_list [Array] list of symbols to select from
|
|
44
|
-
# @return [Symbol] selected symbol
|
|
45
|
-
def prompt_user_input_in_list(prompt, sym_list)
|
|
46
|
-
loop do
|
|
47
|
-
input = prompt_user_input(prompt).to_sym
|
|
48
|
-
return input if sym_list.any? { |a| a.eql?(input) }
|
|
49
|
-
$stderr.puts("No such #{prompt}: #{input}, select one of: #{sym_list.join(', ')}") # rubocop:disable Style/StderrPuts
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
# Characters that erase the last one
|
|
56
|
-
ERASE_CHARS = ["\u007f", "\b"].freeze
|
|
57
|
-
|
|
58
|
-
# Mark of an input checked with `validate`, if valid (`true`) or not: Unicode character, ASCII equivalent, color
|
|
59
|
-
CHECK_MARKS = {
|
|
60
|
-
true => {unicode: '✓', ascii: 'valid', color: :green},
|
|
61
|
-
false => {unicode: '✗', ascii: 'invalid', color: :red}
|
|
62
|
-
}.freeze
|
|
63
|
-
|
|
64
|
-
# Mark shown instead of a hidden input
|
|
65
|
-
Mark = Data.define(:text, :color) do
|
|
66
|
-
# @return [String] Text to display, colored if `color` is set (and colors are enabled)
|
|
67
|
-
def to_s = color.nil? ? text : text.color(color)
|
|
68
|
-
|
|
69
|
-
# @return [String] Characters that erase the mark, by its width on the terminal
|
|
70
|
-
def erase = "\b \b" * Unicode::DisplayWidth.of(text)
|
|
71
|
-
end
|
|
72
|
-
private_constant :ERASE_CHARS, :CHECK_MARKS, :Mark
|
|
73
|
-
|
|
74
|
-
# @param prompt [String] prompt string to display
|
|
75
|
-
# @param sensitive [Boolean] whether to hide typed input
|
|
76
|
-
# @param validate [Proc, nil] Checks the input, for the mark of hidden input
|
|
77
|
-
# @return [String] user input stripped of trailing newline
|
|
78
|
-
def read_input(prompt, sensitive, validate)
|
|
79
|
-
$stderr.print("#{prompt}> ")
|
|
80
|
-
if sensitive && $stdin.tty?
|
|
81
|
-
line = Environment.instance.hidden_silent ? silent_input : masked_input(validate)
|
|
82
|
-
return line unless line.nil?
|
|
83
|
-
end
|
|
84
|
-
read_line
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# @return [String] Line read from standard input, without trailing newline
|
|
88
|
-
def read_line
|
|
89
|
-
line = $stdin.gets
|
|
90
|
-
Aspera.assert_type(line, String) { 'Unexpected end of standard input' }
|
|
91
|
-
line.chomp
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Read a line from the terminal without echoing it, and without any feedback (option `ui.hidden_silent`)
|
|
95
|
-
# @return [String, nil] user input, or `nil` if the terminal cannot disable echo (input not read)
|
|
96
|
-
def silent_input
|
|
97
|
-
line = $stdin.noecho(&:gets)
|
|
98
|
-
$stderr.print("\n")
|
|
99
|
-
Aspera.assert_type(line, String) { 'Unexpected end of standard input' }
|
|
100
|
-
line.chomp
|
|
101
|
-
rescue Errno::ENODEV, Errno::ENOTTY
|
|
102
|
-
nil
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Read a line from the terminal without echoing it, but show a mark instead, without revealing the length of the input:
|
|
106
|
-
# a key while the input is empty (waiting for input), then an ellipsis (the paste worked),
|
|
107
|
-
# or, if the input is checked (`validate`), a check mark if it is valid, else a cross.
|
|
108
|
-
# `terminal_supports_unicode?` checks `stdout`, but the mark is on `stderr`: use the locale only.
|
|
109
|
-
# @param validate [Proc, nil] Checks the input
|
|
110
|
-
# @return [String, nil] user input, or `nil` if the terminal has no raw mode (input not read)
|
|
111
|
-
def masked_input(validate)
|
|
112
|
-
unicode = Environment.unicode_environment?
|
|
113
|
-
line = +''
|
|
114
|
-
mark_of = ->(text) { input_mark(text, validate, unicode) }
|
|
115
|
-
shown = mark_of.call(line)
|
|
116
|
-
$stderr.print(shown)
|
|
117
|
-
begin
|
|
118
|
-
$stdin.raw { |tty| read_masked(tty, line, shown, &mark_of) }
|
|
119
|
-
rescue Errno::ENODEV, Errno::ENOTTY
|
|
120
|
-
# e.g. a pseudo terminal without raw mode: erase the mark, the caller reads a line (echoed)
|
|
121
|
-
$stderr.print(shown.erase)
|
|
122
|
-
return
|
|
123
|
-
end
|
|
124
|
-
line
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# @param line [String] Input
|
|
128
|
-
# @param validate [Proc, nil] Checks the input
|
|
129
|
-
# @param unicode [Boolean] `true` if Unicode is supported
|
|
130
|
-
# @return [Mark] Mark of the input
|
|
131
|
-
def input_mark(line, validate, unicode)
|
|
132
|
-
return Mark.new(Environment.char('🔑', unicode: unicode), nil) if line.empty?
|
|
133
|
-
return Mark.new(Environment.char('…', unicode: unicode), nil) if validate.nil?
|
|
134
|
-
check = CHECK_MARKS[valid?(line, validate)]
|
|
135
|
-
Mark.new(check[unicode ? :unicode : :ascii], check[:color])
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
# @return [Boolean] `true` if `validate` accepts the input
|
|
139
|
-
def valid?(line, validate)
|
|
140
|
-
validate.call(line)
|
|
141
|
-
true
|
|
142
|
-
rescue ParameterError
|
|
143
|
-
false
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Read characters until end of line, and update the mark when the input changes
|
|
147
|
-
# @param tty [IO] Terminal in raw mode
|
|
148
|
-
# @param line [String] Input, filled
|
|
149
|
-
# @param shown [Mark] Mark displayed
|
|
150
|
-
# @yieldparam text [String] Input
|
|
151
|
-
# @yieldreturn [Mark] Mark of the input
|
|
152
|
-
# @return [nil]
|
|
153
|
-
def read_masked(tty, line, shown)
|
|
154
|
-
loop do
|
|
155
|
-
before = line.dup
|
|
156
|
-
char = tty.getc
|
|
157
|
-
case char
|
|
158
|
-
when nil, "\r", "\n" then break
|
|
159
|
-
when "\u0003" then raise Interrupt
|
|
160
|
-
# end of input: Ctrl-D (Unix), Ctrl-Z (Windows)
|
|
161
|
-
when "\u0004", "\u001a"
|
|
162
|
-
break unless line.empty?
|
|
163
|
-
raise Aspera::Error, 'Unexpected end of standard input'
|
|
164
|
-
when *ERASE_CHARS then line.chop!
|
|
165
|
-
# Ctrl-W: erase the last word (and spaces after it), like the terminal does
|
|
166
|
-
when "\u0017" then line.sub!(/\S*\s*\z/, '')
|
|
167
|
-
# Ctrl-U: erase all, e.g. to paste again
|
|
168
|
-
when "\u0015" then line.clear
|
|
169
|
-
else
|
|
170
|
-
# ignore other control characters (and escape sequences start)
|
|
171
|
-
line << char unless char.ord < 32
|
|
172
|
-
end
|
|
173
|
-
next if line.eql?(before)
|
|
174
|
-
mark = yield(line)
|
|
175
|
-
next if mark.eql?(shown)
|
|
176
|
-
$stderr.print(shown.erase, mark)
|
|
177
|
-
shown = mark
|
|
178
|
-
end
|
|
179
|
-
nil
|
|
180
|
-
ensure
|
|
181
|
-
# raw mode: no output processing, a line feed alone does not go back to the first column
|
|
182
|
-
$stderr.print("\r\n")
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
6
|
-
require_relative '../sync/operations'
|
|
7
|
-
require_relative '../assert'
|
|
8
|
-
require_relative '../environment'
|
|
9
|
-
require 'pathname'
|
|
10
|
-
|
|
11
|
-
module Aspera
|
|
12
|
-
module Cli
|
|
13
|
-
# Helpers shared by plugins that expose Aspera Sync (async) operations.
|
|
14
|
-
# Provides DSL registration, argument-to-sync-info conversion, and action methods.
|
|
15
|
-
module SyncActions
|
|
16
|
-
# Translate state id (int) to string
|
|
17
|
-
STATE_STR = (['Nil'] +
|
|
18
|
-
(1..18).map { |i| "P(#{i})" } +
|
|
19
|
-
%w[Syncd Error Confl Pconf] +
|
|
20
|
-
(23..24).map { |i| "P(#{i})" }).freeze
|
|
21
|
-
# Positional arguments shared by sync transfer commands (push/pull/bidi) and sync admin commands.
|
|
22
|
-
PATH_AND_INFO_ARGS = [{name: :path, complete: :folder}, {name: :sync_info, type: Hash, mandatory: false, default: {}}].freeze
|
|
23
|
-
# When a plugin class includes SyncActions, register the :sql option
|
|
24
|
-
# in that class's DSL registry so Base#initialize auto-declares it,
|
|
25
|
-
# and add the class-level DSL methods of ClassMethods.
|
|
26
|
-
class << self
|
|
27
|
-
def included(base)
|
|
28
|
-
base.option(:sql, description: 'SQL suffix appended to sqlite3 queries for admin subcommands (e.g. WHERE clause)')
|
|
29
|
-
base.extend(ClassMethods)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Class-level DSL methods added to the plugin class that includes SyncActions.
|
|
34
|
-
module ClassMethods
|
|
35
|
-
# DSL class method: declare the `sync admin` node and its 7 leaf commands.
|
|
36
|
-
# @param parent [Symbol, Array<Symbol>] path relative to current scope, e.g. :admin
|
|
37
|
-
def sync_admin_commands(parent)
|
|
38
|
-
commands_under(parent, description: 'Manage sync database (admin operations)') do
|
|
39
|
-
command(
|
|
40
|
-
:find, description: 'Find sync database files', arguments: [{name: :path, complete: :folder}],
|
|
41
|
-
action: lambda do |path:, **|
|
|
42
|
-
dbs = Sync::Operations.list_db_files(path)
|
|
43
|
-
Result::ObjectList.new(dbs.keys.map { |n| {name: n, path: dbs[n]} })
|
|
44
|
-
end
|
|
45
|
-
)
|
|
46
|
-
command(
|
|
47
|
-
:status, description: 'Show sync session status', arguments: PATH_AND_INFO_ARGS,
|
|
48
|
-
action: ->(path:, sync_info: {}, **) { Result::SingleObject.new(Sync::Operations.admin_status(async_info_from_args(path: path, sync_info: sync_info))) }
|
|
49
|
-
)
|
|
50
|
-
command(
|
|
51
|
-
:meta, description: 'Show sync session metadata', arguments: PATH_AND_INFO_ARGS,
|
|
52
|
-
action: lambda do |path:, sync_info: {}, **|
|
|
53
|
-
require_relative '../sync/database'
|
|
54
|
-
Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).meta(options.get_option(:sql)))
|
|
55
|
-
end
|
|
56
|
-
)
|
|
57
|
-
command(
|
|
58
|
-
:counters, description: 'Show sync counters', arguments: PATH_AND_INFO_ARGS,
|
|
59
|
-
action: lambda do |path:, sync_info: {}, **|
|
|
60
|
-
require_relative '../sync/database'
|
|
61
|
-
Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).counters(options.get_option(:sql)))
|
|
62
|
-
end
|
|
63
|
-
)
|
|
64
|
-
command(:file_info, description: 'Show per-file sync state', arguments: PATH_AND_INFO_ARGS, action: :action_sync_admin_file_info)
|
|
65
|
-
command(
|
|
66
|
-
:overview, description: 'Show sync database overview', arguments: PATH_AND_INFO_ARGS,
|
|
67
|
-
action: lambda do |path:, sync_info: {}, **|
|
|
68
|
-
require_relative '../sync/database'
|
|
69
|
-
Result::ObjectList.new(db_from_args(path: path, sync_info: sync_info).overview, fields: %w[table name type])
|
|
70
|
-
end
|
|
71
|
-
)
|
|
72
|
-
command(
|
|
73
|
-
:query, description: 'Execute a raw SQL query', arguments: PATH_AND_INFO_ARGS,
|
|
74
|
-
action: lambda do |path:, sync_info: {}, **|
|
|
75
|
-
require_relative '../sync/database'
|
|
76
|
-
Result.auto(db_from_args(path: path, sync_info: sync_info).execute(options.get_option(:sql, mandatory: true)))
|
|
77
|
-
end
|
|
78
|
-
)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Convert path + sync_info to internal `sync_info` format.
|
|
84
|
-
# The resulting sync_info has `args` format only if it contains one of the `sessions` or `instance` keys.
|
|
85
|
-
# It has the `conf` format (default) otherwise.
|
|
86
|
-
# If the `conf` format is detected, then both `local` and `remote` keys are set.
|
|
87
|
-
# @param path [String] local/remote path
|
|
88
|
-
# @param sync_info [Hash] extra sync info (may be empty)
|
|
89
|
-
# @param direction [Symbol,NilClass] one of DIRECTIONS, or nil for admin commands
|
|
90
|
-
# @return [Hash] sync info
|
|
91
|
-
def async_info_from_args(path:, sync_info: {}, direction: nil)
|
|
92
|
-
# is the positional path a remote path ?
|
|
93
|
-
path_is_remote = direction.eql?(:pull)
|
|
94
|
-
if sync_info.key?('sessions') || sync_info.key?('instance')
|
|
95
|
-
# `args`
|
|
96
|
-
sync_info['sessions'] ||= [{}]
|
|
97
|
-
Aspera.assert(sync_info['sessions'].length == 1, 'Only one session is supported')
|
|
98
|
-
session = sync_info['sessions'].first
|
|
99
|
-
dir_key = path_is_remote ? 'remote_dir' : 'local_dir'
|
|
100
|
-
Aspera.assert(!session.key?(dir_key)) { "Parameter #{dir_key} shall not be in sync_info" }
|
|
101
|
-
session[dir_key] = path
|
|
102
|
-
if direction
|
|
103
|
-
dir_key = path_is_remote ? 'local_dir' : 'remote_dir'
|
|
104
|
-
Aspera.assert(!session.key?(dir_key)) { "Parameter #{dir_key} shall not be in sync_info" }
|
|
105
|
-
session[dir_key] = transfer.destination_folder(path_is_remote ? Transfer::Spec::DIRECTION_RECEIVE : Transfer::Spec::DIRECTION_SEND)
|
|
106
|
-
local_remote = %w[local remote].map { |i| session["#{i}_dir"] }
|
|
107
|
-
end
|
|
108
|
-
else
|
|
109
|
-
# `conf`
|
|
110
|
-
session = sync_info
|
|
111
|
-
dir_key = path_is_remote ? 'remote' : 'local'
|
|
112
|
-
session[dir_key] ||= {}
|
|
113
|
-
Aspera.assert(!session[dir_key].key?('path')) { "Parameter #{dir_key}.path shall not be in sync_info" }
|
|
114
|
-
session[dir_key]['path'] = path
|
|
115
|
-
if direction
|
|
116
|
-
dir_key = path_is_remote ? 'local' : 'remote'
|
|
117
|
-
session[dir_key] ||= {}
|
|
118
|
-
Aspera.assert(!session[dir_key].key?('path')) { "Parameter #{dir_key}.path shall not be in sync_info" }
|
|
119
|
-
session[dir_key]['path'] = transfer.destination_folder(path_is_remote ? Transfer::Spec::DIRECTION_RECEIVE : Transfer::Spec::DIRECTION_SEND)
|
|
120
|
-
local_remote = %w[local remote].map { |i| session[i]['path'] }
|
|
121
|
-
end
|
|
122
|
-
# `conf` is quiet by default
|
|
123
|
-
session['quiet'] = false if !session.key?('quiet') && Environment.terminal?
|
|
124
|
-
end
|
|
125
|
-
if direction
|
|
126
|
-
Aspera.assert(!session.key?('direction'), type: BadArgument) { 'direction shall not be in sync_info' }
|
|
127
|
-
session['direction'] = direction.to_s
|
|
128
|
-
# generate name if not provided by user
|
|
129
|
-
if !session.key?('name')
|
|
130
|
-
safe_char = Environment.instance.safe_filename_character
|
|
131
|
-
# from async man page:
|
|
132
|
-
# -N : can contain only ASCII alphanumeric, hyphen, and underscore characters
|
|
133
|
-
session['name'] = Environment.instance.sanitized_filename(
|
|
134
|
-
([direction.to_s] + local_remote).map do |value|
|
|
135
|
-
Pathname(value).each_filename.to_a.last(2).join(safe_char)
|
|
136
|
-
end.join(safe_char).gsub(/[^A-Za-z0-9_-]/, safe_char)
|
|
137
|
-
)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
sync_info
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# Provide database object from path + sync_info for admin ops
|
|
144
|
-
# @param path [String] local path
|
|
145
|
-
# @param sync_info [Hash] extra sync info (may be empty)
|
|
146
|
-
def db_from_args(path:, sync_info: {})
|
|
147
|
-
sync_info = async_info_from_args(path: path, sync_info: sync_info)
|
|
148
|
-
session = sync_info.key?('sessions') ? sync_info['sessions'].first : sync_info
|
|
149
|
-
# if name not provided, check in db folder if there is only one name
|
|
150
|
-
if !session.key?('name')
|
|
151
|
-
local_db_dir = Sync::Operations.local_db_folder(sync_info)
|
|
152
|
-
dbs = Sync::Operations.list_db_files(local_db_dir)
|
|
153
|
-
Aspera.assert(dbs.length == 1) { "#{dbs.length} session found in #{local_db_dir}, please provide a name" }
|
|
154
|
-
session['name'] = dbs.keys.first
|
|
155
|
-
end
|
|
156
|
-
Sync::Database.new(Sync::Operations.session_db_file(sync_info))
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def action_sync_admin_file_info(path:, sync_info: {}, **)
|
|
160
|
-
require_relative '../sync/database'
|
|
161
|
-
result = db_from_args(path: path, sync_info: sync_info).file_info(options.get_option(:sql))
|
|
162
|
-
result.each do |r|
|
|
163
|
-
r['sstate'] = SyncActions::STATE_STR[r['state']] if r['state']
|
|
164
|
-
end
|
|
165
|
-
Result::ObjectList.new(result, fields: %w[sstate record_id f_meta_path message])
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
# Execute a sync transfer for a given direction.
|
|
169
|
-
# @param direction [Symbol] one of Sync::Operations::DIRECTIONS (:push, :pull, :bidi)
|
|
170
|
-
# @param path [String] local or remote path (depends on direction)
|
|
171
|
-
# @param sync_info [Hash] extra sync configuration (may be empty)
|
|
172
|
-
# @param block [Proc, nil] block to generate transfer spec; receives (direction, local_dir, remote_dir)
|
|
173
|
-
def run_sync_transfer(direction, path:, sync_info: {}, &block)
|
|
174
|
-
# Not a transfer of `TransferAgent`: the sync session is started directly
|
|
175
|
-
transfer.assert_no_dry_run
|
|
176
|
-
Sync::Operations.start(async_info_from_args(path: path, sync_info: sync_info, direction: direction), transfer.user_transfer_spec, &block)
|
|
177
|
-
Result::Success.new
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
6
|
-
require_relative 'async_transfer_store'
|
|
7
|
-
require_relative '../agent/factory'
|
|
8
|
-
require_relative '../log'
|
|
9
|
-
require_relative '../assert'
|
|
10
|
-
|
|
11
|
-
module Aspera
|
|
12
|
-
module Cli
|
|
13
|
-
# Mixin for Config plugin: async transfer management actions.
|
|
14
|
-
# Exposes three sub-commands under `config agents jobs` (`config transfer` is a deprecated alias):
|
|
15
|
-
# status <job_id> Re-query a running/completed transfer
|
|
16
|
-
# list List all persisted async transfer entries
|
|
17
|
-
# cleanup Remove completed/failed/cancelled entries
|
|
18
|
-
#
|
|
19
|
-
# Architecture:
|
|
20
|
-
# - remote-daemon agents (desktop, node, connect, transferd): transfer_id + agent_params
|
|
21
|
-
# are persisted in AsyncTransferStore (without secrets, taken from current options);
|
|
22
|
-
# status is re-queried via Agent::Xxx.transfer_status
|
|
23
|
-
# - direct agent: transfers live in Ruby threads - store is the agent's @sessions;
|
|
24
|
-
# status is not persistable across process restarts (returns an informational message)
|
|
25
|
-
module TransferActions
|
|
26
|
-
# Re-query the status of a single async transfer job.
|
|
27
|
-
# @param job_id [String] UUID returned at submission time
|
|
28
|
-
def action_agents_jobs_status(job_id:, **)
|
|
29
|
-
store = async_transfer_store
|
|
30
|
-
entry = store.read(job_id)
|
|
31
|
-
Aspera.assert(!entry.nil?, type: Cli::BadArgument) { "Unknown job_id: #{job_id}" }
|
|
32
|
-
# Secrets are not persisted: take them from current transfer options (e.g. `--transfer`), for the same agent type
|
|
33
|
-
agent_params = current_agent_params(entry['agent_type']).merge(entry['agent_params'] || {})
|
|
34
|
-
# Inject the in-process agent reference (direct/httpgw) if still alive in this process.
|
|
35
|
-
ref = store.agent_ref(job_id)
|
|
36
|
-
agent_params['_agent_ref'] = ref if ref
|
|
37
|
-
live = query_live_status(entry.merge('agent_params' => agent_params))
|
|
38
|
-
if live
|
|
39
|
-
entry.merge!(live)
|
|
40
|
-
store.write(job_id, entry)
|
|
41
|
-
end
|
|
42
|
-
Result::SingleObject.new(entry)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
TERMINAL_STATUSES = %w[completed failed cancelled].freeze
|
|
46
|
-
private_constant :TERMINAL_STATUSES
|
|
47
|
-
|
|
48
|
-
# Delete completed, failed, and cancelled entries from the store.
|
|
49
|
-
def action_agents_jobs_cleanup(**)
|
|
50
|
-
store = async_transfer_store
|
|
51
|
-
deleted = store.list
|
|
52
|
-
.select { |e| TERMINAL_STATUSES.include?(e['status']) }
|
|
53
|
-
.map do |e|
|
|
54
|
-
store.delete(e['job_id'])
|
|
55
|
-
e['job_id']
|
|
56
|
-
end
|
|
57
|
-
Result::Status.new("Deleted #{deleted.size} completed transfer(s)#{": #{deleted.join(', ')}" unless deleted.empty?}")
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
private
|
|
61
|
-
|
|
62
|
-
# @param agent_type [String] agent of the async transfer
|
|
63
|
-
# @return [Hash] agent parameters from current transfer options (e.g. `--transfer`), if for the same agent type
|
|
64
|
-
def current_agent_params(agent_type)
|
|
65
|
-
current = context.transfer.transfer_options
|
|
66
|
-
return {} unless (current['agent'] || 'direct').to_s.eql?(agent_type)
|
|
67
|
-
current.except('agent', 'asynchronous')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Lazy accessor - requires context.persistency (available in all Base sub-classes).
|
|
71
|
-
# Delegate to the TransferAgent's store so that the in-memory agent-ref
|
|
72
|
-
# registry is shared between the two components in the same process.
|
|
73
|
-
def async_transfer_store
|
|
74
|
-
context.transfer.async_store
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Delegate to the appropriate agent class method.
|
|
78
|
-
# All agent types are supported:
|
|
79
|
-
# - in-process agents (direct, httpgw): re-queryable while the same process lives
|
|
80
|
-
# (e.g. MCP mode); '_agent_ref' in agent_params points to the live instance.
|
|
81
|
-
# When the process has restarted, '_agent_ref' is nil and transfer_status returns
|
|
82
|
-
# {'status' => 'unknown'} — which is the correct and safe answer.
|
|
83
|
-
# - daemon agents (node, desktop, connect, transferd): re-query via their REST/IPC API.
|
|
84
|
-
def query_live_status(entry)
|
|
85
|
-
agent_type = entry['agent_type']
|
|
86
|
-
transfer_id = entry['transfer_id']
|
|
87
|
-
agent_params = entry['agent_params'] || {}
|
|
88
|
-
|
|
89
|
-
require "aspera/agent/#{agent_type}"
|
|
90
|
-
agent_class = Aspera::Agent.const_get(agent_type.capitalize)
|
|
91
|
-
agent_class.transfer_status(transfer_id, agent_params)
|
|
92
|
-
rescue StandardError => e
|
|
93
|
-
Log.log.warn { "Could not re-query #{entry['agent_type']} agent for job #{entry['job_id']}: #{e}" }
|
|
94
|
-
nil
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|