aspera-cli 4.28.0 → 4.29.1
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 +0 -0
- data/BUGS.md +5 -10
- data/CHANGELOG.md +217 -2
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +135 -56
- data/GOVERNANCE.md +30 -0
- data/LICENSE +201 -0
- data/README.md +122 -26
- data/SECURITY.md +84 -0
- data/bin/ascli +8 -5
- data/bin/asession +9 -6
- data/docs/README.md +1895 -632
- data/docs/test-mcp-with-ai.md +8 -8
- data/lib/aspera/agent/base.rb +23 -2
- data/lib/aspera/agent/connect.rb +16 -12
- data/lib/aspera/agent/desktop.rb +10 -7
- data/lib/aspera/agent/direct.rb +20 -19
- data/lib/aspera/agent/factory.rb +6 -3
- data/lib/aspera/agent/httpgw.rb +7 -5
- data/lib/aspera/agent/node.rb +15 -7
- data/lib/aspera/agent/transferd.rb +167 -43
- data/lib/aspera/api/alee.rb +4 -1
- data/lib/aspera/api/aoc.rb +14 -11
- data/lib/aspera/api/ats.rb +4 -2
- data/lib/aspera/api/cos_node.rb +7 -4
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +29 -22
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +95 -67
- data/lib/aspera/ascp/log.schema.yaml +1084 -0
- data/lib/aspera/ascp/log_analyzer/advice.rb +97 -0
- data/lib/aspera/ascp/log_analyzer/diagnostics.rb +344 -0
- data/lib/aspera/ascp/log_analyzer/lines.rb +75 -0
- data/lib/aspera/ascp/log_analyzer/log_file.rb +593 -0
- data/lib/aspera/ascp/log_analyzer/records.rb +379 -0
- data/lib/aspera/ascp/log_analyzer/rules.rb +172 -0
- data/lib/aspera/ascp/log_analyzer/session.rb +782 -0
- data/lib/aspera/ascp/log_analyzer.rb +370 -0
- data/lib/aspera/ascp/log_locations.rb +163 -0
- data/lib/aspera/ascp/management.rb +16 -8
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +12 -19
- data/lib/aspera/cli/ascp_logs_actions.rb +188 -0
- data/lib/aspera/cli/async_transfer_store.rb +7 -4
- data/lib/aspera/cli/bootstrapper.rb +38 -33
- data/lib/aspera/cli/command_line.rb +63 -8
- data/lib/aspera/cli/command_registry.rb +9 -1
- data/lib/aspera/cli/command_spec.rb +47 -7
- data/lib/aspera/cli/completion/ascli.bash +19 -5
- data/lib/aspera/cli/completion/ascli.fish +13 -2
- data/lib/aspera/cli/completion/ascli.ps1 +31 -9
- data/lib/aspera/cli/completion/ascli.zsh +22 -6
- data/lib/aspera/cli/completion_actions.rb +303 -69
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +6 -0
- data/lib/aspera/cli/extended_value.rb +66 -31
- data/lib/aspera/cli/formatter.rb +43 -30
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -10
- data/lib/aspera/cli/http.rb +38 -10
- data/lib/aspera/cli/info.rb +12 -7
- data/lib/aspera/cli/mailer.rb +6 -3
- data/lib/aspera/cli/mcp/http_servlet.rb +7 -8
- data/lib/aspera/cli/mcp/secrets.rb +8 -5
- data/lib/aspera/cli/mcp/tool.rb +20 -17
- data/lib/aspera/cli/option_declarator.rb +10 -4
- data/lib/aspera/cli/option_registry.rb +6 -3
- data/lib/aspera/cli/option_types.rb +17 -2
- data/lib/aspera/cli/option_value.rb +77 -18
- data/lib/aspera/cli/options.schema.yaml +641 -80
- data/lib/aspera/cli/parser.rb +71 -35
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +248 -37
- data/lib/aspera/cli/plugins/ats.rb +10 -9
- data/lib/aspera/cli/plugins/base.rb +50 -18
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +210 -104
- data/lib/aspera/cli/plugins/console.rb +6 -3
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +21 -7
- data/lib/aspera/cli/plugins/faspex5.rb +31 -26
- data/lib/aspera/cli/plugins/faspio.rb +7 -5
- data/lib/aspera/cli/plugins/httpgw.rb +7 -4
- data/lib/aspera/cli/plugins/mcp.rb +42 -22
- data/lib/aspera/cli/plugins/node.rb +39 -38
- data/lib/aspera/cli/plugins/oauth.rb +23 -6
- data/lib/aspera/cli/plugins/orchestrator.rb +287 -83
- data/lib/aspera/cli/plugins/preview.rb +72 -45
- data/lib/aspera/cli/plugins/server.rb +66 -14
- data/lib/aspera/cli/plugins/shares.rb +87 -18
- data/lib/aspera/cli/plugins/transferd.rb +228 -0
- data/lib/aspera/cli/poll.rb +236 -0
- data/lib/aspera/cli/preset_actions.rb +144 -30
- data/lib/aspera/cli/preset_manager.rb +113 -35
- data/lib/aspera/cli/prompt.rb +157 -9
- data/lib/aspera/cli/result.rb +12 -8
- data/lib/aspera/cli/runner.rb +89 -48
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +89 -9
- data/lib/aspera/cli/special_values.rb +4 -1
- data/lib/aspera/cli/sync_actions.rb +15 -10
- data/lib/aspera/cli/table_fitter.rb +3 -0
- data/lib/aspera/cli/terminal_formatter.rb +9 -6
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +43 -20
- data/lib/aspera/cli/transfer_progress.rb +14 -45
- data/lib/aspera/cli/vault_actions.rb +45 -0
- data/lib/aspera/cli/vault_manager.rb +188 -42
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.rb +12 -10
- data/lib/aspera/cli/wizard.rb +42 -39
- data/lib/aspera/command_line_builder.rb +9 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +4 -1
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/environment.rb +23 -12
- data/lib/aspera/exec_spec.rb +3 -0
- data/lib/aspera/faspex_gw.rb +13 -9
- data/lib/aspera/faspex_postproc.rb +15 -12
- data/lib/aspera/formatter_interface.rb +4 -1
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +20 -5
- data/lib/aspera/inflate.rb +43 -0
- data/lib/aspera/json_rpc/client.rb +6 -5
- data/lib/aspera/json_rpc/version.rb +3 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +18 -5
- data/lib/aspera/markdown.rb +5 -2
- data/lib/aspera/mime.rb +3 -0
- data/lib/aspera/nagios.rb +6 -4
- data/lib/aspera/node_emulator.rb +15 -13
- data/lib/aspera/oauth/client/base.rb +124 -73
- data/lib/aspera/oauth/client/boot.rb +7 -4
- data/lib/aspera/oauth/client/factory.rb +41 -18
- data/lib/aspera/oauth/client/generic.rb +5 -1
- data/lib/aspera/oauth/client/json_credentials.rb +7 -3
- data/lib/aspera/oauth/client/jwt.rb +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +94 -0
- data/lib/aspera/oauth/client/url_json.rb +7 -3
- data/lib/aspera/oauth/client/web.rb +40 -13
- data/lib/aspera/oauth/server/pkce.rb +6 -5
- data/lib/aspera/orchestrator_workflow_checker.rb +129 -2
- data/lib/aspera/persistency_action_once.rb +5 -3
- data/lib/aspera/persistency_folder.rb +6 -3
- data/lib/aspera/preview/file_types.rb +6 -3
- data/lib/aspera/preview/generator.rb +9 -5
- data/lib/aspera/preview/options.schema.yaml +3 -3
- data/lib/aspera/preview/terminal.rb +16 -6
- data/lib/aspera/preview/utils.rb +6 -4
- data/lib/aspera/products/connect.rb +5 -2
- data/lib/aspera/products/desktop.rb +17 -2
- data/lib/aspera/products/other.rb +4 -2
- data/lib/aspera/products/transferd.rb +6 -2
- data/lib/aspera/products/transferd_service.rb +610 -0
- data/lib/aspera/proxy_auto_config.js +2 -2
- data/lib/aspera/proxy_auto_config.rb +5 -2
- data/lib/aspera/rainbow.rb +3 -0
- data/lib/aspera/rest/aspera_errors.rb +4 -1
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +45 -34
- data/lib/aspera/rest/error_analyzer.rb +5 -2
- data/lib/aspera/rest/list.rb +8 -4
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +8 -5
- data/lib/aspera/rest.rb +9 -6
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +118 -30
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +11 -11
- data/lib/aspera/schema/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +2437 -1437
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +8 -2
- data/lib/aspera/schema/reader.rb +7 -0
- data/lib/aspera/schema/registry.rb +44 -28
- data/lib/aspera/schema/transferd-config.schema.json +333 -0
- data/lib/aspera/schema/validator.rb +4 -1
- data/lib/aspera/sealed_hash.rb +150 -0
- data/lib/aspera/secret/hider.rb +213 -0
- data/lib/aspera/secret/reference.rb +150 -0
- data/lib/aspera/secret/resolver.rb +212 -0
- data/lib/aspera/secret/store/base.rb +153 -0
- data/lib/aspera/secret/store/encrypted_hash.rb +329 -0
- data/lib/aspera/secret/store/factory.rb +103 -0
- data/lib/aspera/secret/store/hashicorp_vault.rb +390 -0
- data/lib/aspera/secret/store/keeper.rb +141 -0
- data/lib/aspera/secret/store/macos_security.rb +284 -0
- data/lib/aspera/secret/store/one_password_api.rb +99 -0
- data/lib/aspera/secret/store/one_password_base.rb +42 -0
- data/lib/aspera/secret/store/one_password_cli.rb +112 -0
- data/lib/aspera/secret/store/secret_service.rb +125 -0
- data/lib/aspera/secret/strength.rb +119 -0
- data/lib/aspera/servlet_helpers.rb +5 -2
- data/lib/aspera/ssh.rb +10 -7
- data/lib/aspera/ssl.rb +5 -2
- data/lib/aspera/string_ext.rb +3 -0
- data/lib/aspera/sync/args.schema.yaml +3 -0
- data/lib/aspera/sync/conf.schema.yaml +9 -4
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +17 -15
- data/lib/aspera/temp_file_manager.rb +8 -4
- data/lib/aspera/timer_limiter.rb +3 -0
- data/lib/aspera/transfer/error.rb +4 -1
- data/lib/aspera/transfer/faux_file.rb +4 -1
- data/lib/aspera/transfer/parameters.rb +17 -14
- data/lib/aspera/transfer/result.rb +23 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +9 -22
- data/lib/aspera/units/decimal.rb +67 -0
- data/lib/aspera/units/duration.rb +109 -0
- data/lib/aspera/uri_reader.rb +64 -9
- data/lib/aspera/web_auth/index.html.erb +6 -2
- data/lib/aspera/web_auth/paste.rb +109 -0
- data/lib/aspera/web_auth/receiver.rb +50 -0
- data/lib/aspera/web_auth/relay.rb +76 -0
- data/lib/aspera/web_auth/reply.html.erb +150 -0
- data/lib/aspera/web_auth/server.rb +47 -10
- data/lib/aspera/web_page.rb +7 -2
- data/lib/aspera/web_server_simple.rb +6 -3
- data/lib/aspera/yaml.rb +5 -1
- data/llms-install.md +88 -0
- data/llms.txt +87 -0
- data/skills/ascli/SKILL.md +94 -0
- data.tar.gz.sig +0 -0
- metadata +77 -20
- metadata.gz.sig +0 -0
- data/lib/aspera/duration.rb +0 -42
- data/lib/aspera/keychain/base.rb +0 -30
- data/lib/aspera/keychain/encrypted_hash.rb +0 -192
- data/lib/aspera/keychain/factory.rb +0 -58
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -77
- data/lib/aspera/keychain/macos_security.rb +0 -277
- data/lib/aspera/keychain/one_password_api.rb +0 -91
- data/lib/aspera/keychain/one_password_base.rb +0 -39
- data/lib/aspera/keychain/one_password_cli.rb +0 -100
- data/lib/aspera/secret_hider.rb +0 -196
- data/lib/aspera/secret_strength.rb +0 -114
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'info'
|
|
7
|
+
require_relative 'parser'
|
|
8
|
+
require_relative 'plugins/factory'
|
|
9
|
+
require_relative 'preset_manager'
|
|
10
|
+
require_relative 'special_values'
|
|
11
|
+
require_relative '../environment'
|
|
12
|
+
require_relative '../schema/documentation'
|
|
13
|
+
require_relative '../schema/registry'
|
|
10
14
|
|
|
11
15
|
module Aspera
|
|
12
16
|
module Cli
|
|
@@ -16,33 +20,66 @@ module Aspera
|
|
|
16
20
|
COMPLETION_SHELLS = {bash: 'bash', zsh: 'zsh', fish: 'fish', powershell: 'ps1'}.freeze
|
|
17
21
|
COMPLETION_FOLDER = File.expand_path('completion', __dir__)
|
|
18
22
|
# Completion of the word at cursor
|
|
19
|
-
# @!attribute candidates
|
|
20
|
-
# @!attribute hint
|
|
21
|
-
# @!attribute files
|
|
22
|
-
|
|
23
|
+
# @!attribute candidates [Array<Array(String, String)>] words, with their description (or `nil`)
|
|
24
|
+
# @!attribute hint [String, nil] displayed when a value is expected, but cannot be proposed (e.g. `<String>`)
|
|
25
|
+
# @!attribute files [Symbol, nil] local paths are completed: `:file` (files and folders) or `:folder`
|
|
26
|
+
# @!attribute files_prefix [String, nil] beginning of the word at cursor that is not part of the path (e.g. `@file:`)
|
|
27
|
+
Completion = Struct.new(:candidates, :hint, :files, :files_prefix, keyword_init: true) do
|
|
28
|
+
# Completion of a value that follows the given text in the word at cursor
|
|
29
|
+
# @param prefix [String] beginning of the word at cursor
|
|
30
|
+
# @return [self]
|
|
31
|
+
def prefixed(prefix)
|
|
32
|
+
self.candidates = candidates.map { |word, description| ["#{prefix}#{word}", description] }
|
|
33
|
+
self.files_prefix = "#{prefix}#{files_prefix}"
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
end
|
|
23
37
|
# Structure built with `@:` (see `Parser#args_as_extended`) being typed
|
|
24
|
-
# @!attribute marker
|
|
25
|
-
# @!attribute
|
|
26
|
-
# @!attribute option
|
|
27
|
-
Collecting = Struct.new(:marker, :
|
|
38
|
+
# @!attribute marker [String] end marker
|
|
39
|
+
# @!attribute assigned [Array<String>] paths assigned
|
|
40
|
+
# @!attribute option [Option, nil] option token whose value is built, `nil` for a positional argument
|
|
41
|
+
Collecting = Struct.new(:marker, :assigned, :option, keyword_init: true)
|
|
42
|
+
# Command reached by the positional words
|
|
43
|
+
# @!attribute registry [CommandRegistry, nil] registry of plugin, `nil` at root
|
|
44
|
+
# @!attribute path [Array<Symbol>, nil] command path, `nil` if words are not a command
|
|
45
|
+
# @!attribute arguments [Array<String>] arguments given to the command
|
|
46
|
+
Position = Struct.new(:registry, :path, :arguments, keyword_init: true) do
|
|
47
|
+
# @return [CommandSpec, nil] command reached
|
|
48
|
+
def spec = path && registry[path]
|
|
49
|
+
end
|
|
28
50
|
# Value starting a structure built with `@:`: the optional text after `:` is the end marker
|
|
29
51
|
REGEX_EXTEND_ARGS = /\A@:(.*)\z/
|
|
52
|
+
# Extended value modifier at the beginning of a value, e.g. `@file:`
|
|
53
|
+
REGEX_MODIFIER = /\A@([a-z0-9_]*):/
|
|
54
|
+
# Beginning of extended value
|
|
55
|
+
MARKER_MODIFIER = '@'
|
|
56
|
+
# Modifiers whose value is usually given by another modifier, e.g. `@json:@file:`
|
|
57
|
+
MODIFIERS_DECODING = %i[base64 csvt json lines list re ruby s yaml zlib].freeze
|
|
58
|
+
# Modifiers whose value is not evaluated
|
|
59
|
+
MODIFIERS_LITERAL = %i[val extend].freeze
|
|
60
|
+
# Modes of `@stdin:`
|
|
61
|
+
STDIN_MODES = ['', 'bin', 'chomp'].freeze
|
|
62
|
+
# End of sentence in a description: a period, not of `e.g.` or `i.e.`, followed by a word not in lower case
|
|
63
|
+
REGEX_SENTENCE_END = /(?<!\be\.g|\bi\.e)\.\s+(?=[^a-z])/
|
|
30
64
|
# Maximum length of a hint listing the keys of a structure
|
|
31
65
|
HINT_MAX_LENGTH = 72
|
|
32
|
-
private_constant :COMPLETION_SHELLS, :COMPLETION_FOLDER, :Completion, :Collecting, :REGEX_EXTEND_ARGS, :
|
|
66
|
+
private_constant :COMPLETION_SHELLS, :COMPLETION_FOLDER, :Completion, :Collecting, :Position, :REGEX_EXTEND_ARGS, :REGEX_MODIFIER,
|
|
67
|
+
:MARKER_MODIFIER, :MODIFIERS_DECODING, :MODIFIERS_LITERAL, :STDIN_MODES, :REGEX_SENTENCE_END, :HINT_MAX_LENGTH
|
|
33
68
|
|
|
34
69
|
# List words that can follow the given words, one per line.
|
|
35
|
-
# When a value is expected but cannot be proposed, its type is listed (e.g. `<String>`).
|
|
70
|
+
# When a value is expected but cannot be proposed, its type is listed (e.g. `<String>`), or `<file>` (or `<folder>`) for a local path.
|
|
36
71
|
# @param words [Array<String>, nil] words typed before the cursor, after the command name
|
|
37
72
|
def action_completion_words(words: nil, **)
|
|
38
73
|
completion = completion(Array(words), '')
|
|
39
74
|
completion.candidates.each { |candidate| puts candidate.first }
|
|
40
75
|
puts completion.hint unless completion.hint.nil?
|
|
41
|
-
|
|
76
|
+
puts "<#{completion.files}>" unless completion.files.nil?
|
|
77
|
+
::Process.exit(0)
|
|
42
78
|
end
|
|
43
79
|
|
|
44
80
|
# Complete the word at cursor, for completion scripts: candidates, one per line: `word`, or `word<TAB>description`,
|
|
45
|
-
# not filtered by the word at cursor. Then a directive for the shell: `:files` (
|
|
81
|
+
# not filtered by the word at cursor. Then a directive for the shell: `:files` or `:folders` (complete local paths),
|
|
82
|
+
# followed by a space and the beginning of the word at cursor that is not part of the path, if any (e.g. `--key=@file:`),
|
|
46
83
|
# `:hint <text>` (display text, nothing to insert), or `:`.
|
|
47
84
|
# @param words [Array<String>, nil] words typed before the cursor, after the command name, then the word at cursor
|
|
48
85
|
def action_completion_candidates(words: nil, **)
|
|
@@ -50,11 +87,11 @@ module Aspera
|
|
|
50
87
|
completion = completion(words[0..-2], words.last.to_s)
|
|
51
88
|
completion.candidates.each { |word, description| puts description.nil? ? word : "#{word}\t#{description}" }
|
|
52
89
|
directive =
|
|
53
|
-
if completion.files then 'files'
|
|
90
|
+
if completion.files then [completion.files.eql?(:folder) ? 'folders' : 'files', completion.files_prefix].reject { |w| w.to_s.empty? }.join(' ')
|
|
54
91
|
elsif completion.hint then "hint #{completion.hint}"
|
|
55
92
|
end
|
|
56
93
|
puts ":#{directive}"
|
|
57
|
-
Process.exit(0)
|
|
94
|
+
::Process.exit(0)
|
|
58
95
|
end
|
|
59
96
|
|
|
60
97
|
private
|
|
@@ -64,28 +101,38 @@ module Aspera
|
|
|
64
101
|
# @return [Completion]
|
|
65
102
|
def completion(words, current)
|
|
66
103
|
words = completion_join_bash_split(words)
|
|
67
|
-
# `--opt=value`: complete the value of the option, with this prefix
|
|
68
|
-
prefix =
|
|
104
|
+
# `--opt=value` or `-Ovalue`: complete the value of the option, with this prefix
|
|
105
|
+
prefix = completion_inline_prefix(current)
|
|
69
106
|
words += [prefix] unless prefix.empty?
|
|
70
107
|
plugin_class, positional, waiting, collecting = completion_context(words)
|
|
71
108
|
return Completion.new(candidates: []) if positional.nil?
|
|
109
|
+
position = completion_position(plugin_class, positional)
|
|
110
|
+
value = current[prefix.length..]
|
|
72
111
|
result =
|
|
73
|
-
if prefix.empty? && (keys = completion_option_keys(current))
|
|
112
|
+
if prefix.empty? && (keys = completion_option_keys(current, position))
|
|
74
113
|
keys
|
|
75
114
|
elsif prefix.empty? && current.start_with?('-')
|
|
76
115
|
Completion.new(candidates: completion_options(options.declared_options.keys))
|
|
77
116
|
elsif !waiting.nil?
|
|
78
|
-
completion_option_values(waiting)
|
|
117
|
+
completion_option_values(waiting, value, position)
|
|
79
118
|
elsif !collecting.nil?
|
|
80
|
-
completion_collecting(collecting, plugin_class, positional)
|
|
119
|
+
completion_collecting(collecting, value, plugin_class, positional, position)
|
|
81
120
|
elsif plugin_class.nil?
|
|
82
121
|
# Level 0: plugin names and global options
|
|
83
122
|
Completion.new(candidates: Plugins::Factory.instance.plugin_list.map { |p| [p.to_s, completion_plugin_description(p)] } + completion_options(options.declared_options.keys))
|
|
84
123
|
else
|
|
85
|
-
completion_command(plugin_class, positional[1..])
|
|
124
|
+
completion_command(plugin_class, positional[1..], value, position)
|
|
86
125
|
end
|
|
87
|
-
result.
|
|
88
|
-
|
|
126
|
+
result.prefixed(prefix)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @param current [String] word at cursor
|
|
130
|
+
# @return [String] part of the word that precedes the value of an option given in the same word: `--opt=` or `-O`, empty if none
|
|
131
|
+
def completion_inline_prefix(current)
|
|
132
|
+
return current[0..current.index(Option::VALUE_SEP)] if current.start_with?(Option::PREFIX) && current.include?(Option::VALUE_SEP)
|
|
133
|
+
return '' if current.start_with?(Option::PREFIX) || !Option.option?(current)
|
|
134
|
+
short = completion_option(Option.parse(current[0, 2]))
|
|
135
|
+
short.nil? || short.flag? ? '' : current[0, 2]
|
|
89
136
|
end
|
|
90
137
|
|
|
91
138
|
# @param words [Array<String>] words typed before the cursor
|
|
@@ -106,6 +153,16 @@ module Aspera
|
|
|
106
153
|
[plugin_class, *completion_split(words)]
|
|
107
154
|
end
|
|
108
155
|
|
|
156
|
+
# @param plugin_class [Class, nil] plugin
|
|
157
|
+
# @param positional [Array<String>] positional words, the plugin name first
|
|
158
|
+
# @return [Position] command reached by the positional words
|
|
159
|
+
def completion_position(plugin_class, positional)
|
|
160
|
+
return Position.new(arguments: []) if plugin_class.nil?
|
|
161
|
+
registry = plugin_class.command_registry
|
|
162
|
+
path, given = registry.command_position(positional[1..].map(&:to_sym))
|
|
163
|
+
Position.new(registry: registry, path: path, arguments: path.nil? || given.zero? ? [] : positional.last(given))
|
|
164
|
+
end
|
|
165
|
+
|
|
109
166
|
# As the runner: an exact name, else the unique plugin name starting with word
|
|
110
167
|
# @param word [String] first positional word
|
|
111
168
|
# @return [Symbol, nil] plugin designated by word
|
|
@@ -118,16 +175,18 @@ module Aspera
|
|
|
118
175
|
|
|
119
176
|
# @param plugin_class [Class] plugin
|
|
120
177
|
# @param words [Array<String>] positional words after the plugin name
|
|
178
|
+
# @param value [String] word at cursor
|
|
179
|
+
# @param position [Position] command reached
|
|
121
180
|
# @return [Completion] sub-commands, or next argument
|
|
122
|
-
def completion_command(plugin_class, words)
|
|
181
|
+
def completion_command(plugin_class, words, value, position)
|
|
123
182
|
registry = plugin_class.command_registry
|
|
124
|
-
path
|
|
183
|
+
path = position.path
|
|
125
184
|
return Completion.new(candidates: []) if path.nil?
|
|
126
185
|
children = registry.children_of(path)
|
|
127
|
-
next_argument = completion_next_argument(registry, path,
|
|
128
|
-
return completion_argument(next_argument) unless next_argument.nil?
|
|
186
|
+
next_argument = completion_next_argument(registry, path, position.arguments.length)
|
|
187
|
+
return completion_argument(next_argument, value, position) unless next_argument.nil?
|
|
129
188
|
# Source files of an upload follow the declared arguments
|
|
130
|
-
return Completion.new(candidates: [], files:
|
|
189
|
+
return Completion.new(candidates: [], files: :file) if children.empty? && registry[path]&.transfer_paths.eql?(:send)
|
|
131
190
|
# Commands, each followed by its aliases, with the same description
|
|
132
191
|
candidates = children.flat_map do |id, spec|
|
|
133
192
|
description = completion_description(spec.description)
|
|
@@ -148,23 +207,32 @@ module Aspera
|
|
|
148
207
|
arguments.last if registry.children_of(path).empty? && arguments.last&.multiple
|
|
149
208
|
end
|
|
150
209
|
|
|
151
|
-
# In a structure built with `@:`: its end marker once an assignment is given,
|
|
210
|
+
# In a structure built with `@:`: the keys of its schema, and its end marker once an assignment is given, or the value of a key
|
|
152
211
|
# @param collecting [Collecting] structure being typed
|
|
212
|
+
# @param value [String] word at cursor: `path`, or `path=value`
|
|
153
213
|
# @param plugin_class [Class, nil] plugin
|
|
154
214
|
# @param positional [Array<String>] positional words, the plugin name first
|
|
215
|
+
# @param position [Position] command reached
|
|
155
216
|
# @return [Completion]
|
|
156
|
-
def completion_collecting(collecting, plugin_class, positional)
|
|
157
|
-
return Completion.new(candidates: [[collecting.marker, 'End of structure built with @:']]) if collecting.assignments.positive?
|
|
217
|
+
def completion_collecting(collecting, value, plugin_class, positional, position)
|
|
158
218
|
schema =
|
|
159
219
|
if collecting.option
|
|
160
|
-
completion_option(collecting.option)
|
|
220
|
+
option = completion_option(collecting.option)
|
|
221
|
+
completion_option_schema(option, position) unless option.nil?
|
|
161
222
|
elsif plugin_class
|
|
162
223
|
# The positional argument built is the last positional word: `@:`
|
|
163
224
|
registry = plugin_class.command_registry
|
|
164
225
|
path, given = registry.command_position(positional[1..-2].map(&:to_sym))
|
|
165
226
|
completion_next_argument(registry, path, given)&.schema unless path.nil?
|
|
166
227
|
end
|
|
167
|
-
|
|
228
|
+
if (index = value.index(Option::VALUE_SEP))
|
|
229
|
+
return completion_key_value(schema, value[0...index].split(DotContainer::SEPARATOR), value[(index + 1)..], position).prefixed(value[0..index])
|
|
230
|
+
end
|
|
231
|
+
end_marker = collecting.assigned.empty? ? [] : [[collecting.marker, 'End of structure built with @:']]
|
|
232
|
+
# The value of an option may be partial (completed by other sources): required keys apply to an argument only
|
|
233
|
+
keys = completion_schema_keys(completion_schema_rows(schema), value, assigned: collecting.assigned, required: collecting.option.nil?)
|
|
234
|
+
return Completion.new(candidates: [], hint: completion_hint('path=value', nil)) if end_marker.empty? && keys.empty?
|
|
235
|
+
Completion.new(candidates: end_marker + keys)
|
|
168
236
|
end
|
|
169
237
|
|
|
170
238
|
# Bash splits `--opt=value` in words `--opt`, `=` and `value`: join them back.
|
|
@@ -212,8 +280,11 @@ module Aspera
|
|
|
212
280
|
waiting = nil
|
|
213
281
|
elsif collecting
|
|
214
282
|
# Assignment, or end marker
|
|
215
|
-
collecting.
|
|
216
|
-
|
|
283
|
+
if word.eql?(collecting.marker)
|
|
284
|
+
collecting = nil
|
|
285
|
+
else
|
|
286
|
+
collecting.assigned.push(word.split(Option::VALUE_SEP, 2).first)
|
|
287
|
+
end
|
|
217
288
|
else
|
|
218
289
|
positional.push(word)
|
|
219
290
|
collecting = completion_collecting_start(word, nil)
|
|
@@ -228,7 +299,7 @@ module Aspera
|
|
|
228
299
|
def completion_collecting_start(value, option)
|
|
229
300
|
match = REGEX_EXTEND_ARGS.match(value.to_s)
|
|
230
301
|
return if match.nil?
|
|
231
|
-
Collecting.new(marker: match[1].empty? ? SpecialValues::EOA : match[1],
|
|
302
|
+
Collecting.new(marker: match[1].empty? ? SpecialValues::EOA : match[1], assigned: [], option: option)
|
|
232
303
|
end
|
|
233
304
|
|
|
234
305
|
# @param tok [Option] option token
|
|
@@ -238,6 +309,14 @@ module Aspera
|
|
|
238
309
|
options.declared_options[tok.name.to_sym]
|
|
239
310
|
end
|
|
240
311
|
|
|
312
|
+
# @param option [OptionValue] declared option
|
|
313
|
+
# @param position [Position] command reached
|
|
314
|
+
# @return [String, nil] schema of the value of option: the one of option `query` depends on the command
|
|
315
|
+
def completion_option_schema(option, position)
|
|
316
|
+
return option.schema unless option.schema.nil? && option.option.eql?(:query)
|
|
317
|
+
position.spec&.query_schema
|
|
318
|
+
end
|
|
319
|
+
|
|
241
320
|
# @param names [Array<Symbol>] names of declared options
|
|
242
321
|
# @return [Array<Array(String, String)>] command line names of options, except deprecated ones, and their description
|
|
243
322
|
def completion_options(names)
|
|
@@ -248,42 +327,193 @@ module Aspera
|
|
|
248
327
|
end
|
|
249
328
|
end
|
|
250
329
|
|
|
251
|
-
# @param tok
|
|
330
|
+
# @param tok [Option] option token waiting for its value
|
|
331
|
+
# @param value [String] value typed
|
|
332
|
+
# @param position [Position] command reached
|
|
252
333
|
# @return [Completion] allowed values of the option, or its type as hint
|
|
253
|
-
def completion_option_values(tok)
|
|
334
|
+
def completion_option_values(tok, value, position)
|
|
254
335
|
option = completion_option(tok)
|
|
255
|
-
|
|
256
|
-
return
|
|
257
|
-
|
|
336
|
+
# Option not declared yet (e.g. of a plugin): its value may still be an extended value
|
|
337
|
+
return completion_value(value, position, hint: nil) if option.nil?
|
|
338
|
+
schema = completion_option_schema(option, position)
|
|
339
|
+
return completion_key_value(schema, tok.dot_path, value, position) unless tok.dot_path.nil?
|
|
340
|
+
allowed = option.values&.map(&:to_s)&.uniq
|
|
341
|
+
complete = option.complete
|
|
342
|
+
# A String value is the value of a key of the structure
|
|
343
|
+
allowed, complete = completion_shorthand(schema, option.shorthand) if allowed.nil? && complete.nil? && option.shorthand
|
|
258
344
|
types = option.types&.reject { |t| t.eql?(NilClass) }
|
|
259
|
-
|
|
345
|
+
hint = completion_hint(types&.any? ? types.map(&:name).join('|') : option.allowed_info || 'String', schema)
|
|
346
|
+
completion_value(value, position, hint: hint, allowed: allowed, complete: complete)
|
|
260
347
|
end
|
|
261
348
|
|
|
262
|
-
#
|
|
263
|
-
# @param
|
|
349
|
+
# @param schema [String, nil] schema of structure
|
|
350
|
+
# @param key [String] key of a `String` value
|
|
351
|
+
# @return [Array(Array<String>, Symbol)] allowed values of the key, from its schema or the discriminator of its variants, and kind of value
|
|
352
|
+
def completion_shorthand(schema, key)
|
|
353
|
+
row = completion_schema_row(schema, [key])
|
|
354
|
+
return [completion_row_values(row), row['complete']&.to_sym] unless row.nil?
|
|
355
|
+
node = Schema::Registry.instance.reader(schema).current
|
|
356
|
+
[(node.dig('discriminator', 'mapping')&.keys if node.dig('discriminator', 'propertyName').eql?(key)), nil]
|
|
357
|
+
rescue StandardError
|
|
358
|
+
[nil, nil]
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Keys of an option with dotted notation, from its schema, e.g. `--ts.ta` gives `--ts.target_rate_kbps=`
|
|
362
|
+
# @param current [String] word at cursor
|
|
363
|
+
# @param position [Position] command reached
|
|
264
364
|
# @return [Completion, nil] keys at the level of the word, `nil` if the word is not a dotted option
|
|
265
|
-
def completion_option_keys(current)
|
|
365
|
+
def completion_option_keys(current, position)
|
|
266
366
|
match = current.match(/\A--([^=.]+)\.([^=]*)\z/)
|
|
267
367
|
return if match.nil?
|
|
268
368
|
option = options.declared_options[Parser.option_line_to_name(match[1]).to_sym]
|
|
269
|
-
|
|
270
|
-
|
|
369
|
+
return Completion.new(candidates: []) if option.nil?
|
|
370
|
+
rows = completion_schema_rows(completion_option_schema(option, position))
|
|
371
|
+
Completion.new(candidates: completion_schema_keys(rows, match[2])).prefixed("#{Option::PREFIX}#{match[1]}#{DotContainer::SEPARATOR}")
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
# Keys of a structure at the level of the path typed: `key=` for a value, `key.` for a structure, `key.0.` for a list of structures.
|
|
375
|
+
# @param rows [Array<Hash>] fields of schema
|
|
376
|
+
# @param typed [String] path typed: dot-separated keys, the last one being typed
|
|
377
|
+
# @param assigned [Array<String>] paths already assigned, not proposed again
|
|
378
|
+
# @param required [Boolean] required keys are marked, and listed first
|
|
379
|
+
# @return [Array<Array(String, String)>] path of key, and its description
|
|
380
|
+
def completion_schema_keys(rows, typed, assigned: [], required: false)
|
|
381
|
+
# Keys of parents, as typed, e.g. `recipients.0.`
|
|
382
|
+
parents = typed[0, (typed.rindex(DotContainer::SEPARATOR) || -1) + 1]
|
|
383
|
+
parent_path = completion_row_path(parents.split(DotContainer::SEPARATOR))
|
|
384
|
+
names = rows.map { |r| r['name'] }
|
|
385
|
+
keys = rows.filter_map do |row|
|
|
271
386
|
path = row['name'].split(DotContainer::SEPARATOR)
|
|
272
|
-
next
|
|
273
|
-
|
|
387
|
+
next unless path[0..-2].eql?(parent_path)
|
|
388
|
+
suffix =
|
|
389
|
+
if names.any? { |n| n.start_with?("#{row['name']}#{DotContainer::SEPARATOR}") } then DotContainer::SEPARATOR
|
|
390
|
+
elsif names.any? { |n| n.start_with?("#{row['name']}[]#{DotContainer::SEPARATOR}") } then "#{DotContainer::SEPARATOR}0#{DotContainer::SEPARATOR}"
|
|
391
|
+
else Option::VALUE_SEP
|
|
392
|
+
end
|
|
393
|
+
key = "#{parents}#{path.last}"
|
|
394
|
+
next if suffix.eql?(Option::VALUE_SEP) && assigned.include?(key)
|
|
395
|
+
description = completion_description(row['description']) || completion_type(row['type'])
|
|
396
|
+
description = [description, '(required)'].compact.join(' ') if required && row['required']
|
|
397
|
+
["#{key}#{suffix}", description, required && row['required']]
|
|
274
398
|
end
|
|
275
|
-
|
|
399
|
+
keys.partition(&:last).flatten(1).map { |key, description, _| [key, description] }
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
# @param keys [Array<String>] keys of a path, as typed, e.g. `recipients`, `0`, `name`
|
|
403
|
+
# @return [Array<String>] keys of the path, as in schema rows, e.g. `recipients[]`, `name`
|
|
404
|
+
def completion_row_path(keys)
|
|
405
|
+
keys.each_with_object([]) do |key, path|
|
|
406
|
+
if !path.empty? && key.match?(/\A\d+\z/)
|
|
407
|
+
path[-1] = "#{path.last}[]"
|
|
408
|
+
else
|
|
409
|
+
path.push(key)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# @param schema [String, nil] schema of structure
|
|
415
|
+
# @param keys [Array<String>] path of key in structure, as typed
|
|
416
|
+
# @return [Hash, nil] field of the schema at path
|
|
417
|
+
def completion_schema_row(schema, keys)
|
|
418
|
+
name = completion_row_path(keys).join(DotContainer::SEPARATOR)
|
|
419
|
+
completion_schema_rows(schema).find { |r| r['name'].eql?(name) }
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# @param row [Hash] field of schema
|
|
423
|
+
# @return [Array<String>, nil] allowed values of the field
|
|
424
|
+
def completion_row_values(row)
|
|
425
|
+
return row['enum'].compact.map(&:to_s) if row['enum']
|
|
426
|
+
%w[true false] if row['type'].eql?('boolean')
|
|
276
427
|
end
|
|
277
428
|
|
|
278
429
|
# @param schema [String, nil] schema of structure
|
|
279
|
-
# @param
|
|
430
|
+
# @param keys [Array<String>] path of key in structure, as typed
|
|
431
|
+
# @param value [String] value typed
|
|
432
|
+
# @param position [Position] command reached
|
|
280
433
|
# @return [Completion] allowed values of the key, or its type as hint
|
|
281
|
-
def completion_key_value(schema,
|
|
282
|
-
row =
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
434
|
+
def completion_key_value(schema, keys, value, position)
|
|
435
|
+
row = completion_schema_row(schema, keys)
|
|
436
|
+
return completion_value(value, position, hint: nil) if row.nil?
|
|
437
|
+
type = completion_type(row['type'])
|
|
438
|
+
hint = ["<#{type.empty? ? 'value' : type}>", completion_description(row['description'])].compact.join(' ')
|
|
439
|
+
completion_value(value, position, hint: hint, allowed: completion_row_values(row), complete: row['complete']&.to_sym)
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
# @param value [String] value typed
|
|
443
|
+
# @param position [Position] command reached
|
|
444
|
+
# @param hint [String, nil] hint, when nothing can be proposed
|
|
445
|
+
# @param allowed [Array<String>, nil] allowed values
|
|
446
|
+
# @param complete [Symbol, nil] kind of value, one of `Complete::KINDS`
|
|
447
|
+
# @param extended [Boolean] the value is evaluated as extended value
|
|
448
|
+
# @return [Completion] values: extended value modifiers, allowed values, local values, or hint
|
|
449
|
+
def completion_value(value, position, hint:, allowed: nil, complete: nil, extended: true)
|
|
450
|
+
return completion_extended(value, position, complete) if extended && value.start_with?(MARKER_MODIFIER)
|
|
451
|
+
return Completion.new(candidates: allowed.map { |v| [v, nil] }) unless allowed.nil? || allowed.empty?
|
|
452
|
+
(completion_kind(complete, value, position) unless complete.nil?) || Completion.new(candidates: [], hint: hint)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
# @param kind [Symbol] kind of value, one of `Complete::KINDS`
|
|
456
|
+
# @param value [String] value typed
|
|
457
|
+
# @param position [Position] command reached
|
|
458
|
+
# @return [Completion, nil] values of this kind, `nil` if none applies
|
|
459
|
+
def completion_kind(kind, value, position)
|
|
460
|
+
case kind
|
|
461
|
+
when :file, :folder then Completion.new(candidates: [], files: kind)
|
|
462
|
+
when :destination_folder then Completion.new(candidates: [], files: :folder) unless position.spec&.transfer_paths.eql?(:send)
|
|
463
|
+
when :preset then Completion.new(candidates: completion_preset_names(value))
|
|
464
|
+
when :preset_parameter then Completion.new(candidates: completion_preset_parameters(position.arguments.first))
|
|
465
|
+
when :transfer_job then Completion.new(candidates: async_transfer_store.list.map { |job| [job['job_id'].to_s, job['status']] })
|
|
466
|
+
else Aspera.error_unexpected_value(kind) { 'complete' }
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
# Value starting with `@`: modifiers, or the value of the last modifier, e.g. a local file for `@file:`
|
|
471
|
+
# @param value [String] value typed, starting with `@`
|
|
472
|
+
# @param position [Position] command reached
|
|
473
|
+
# @param complete [Symbol, nil] kind of value, one of `Complete::KINDS`
|
|
474
|
+
# @return [Completion]
|
|
475
|
+
def completion_extended(value, position, complete)
|
|
476
|
+
modifiers = ExtendedValue.instance.modifiers
|
|
477
|
+
last = nil
|
|
478
|
+
rest = value
|
|
479
|
+
while !MODIFIERS_LITERAL.include?(last) && (match = REGEX_MODIFIER.match(rest)) && modifiers.include?(match[1].to_sym)
|
|
480
|
+
last = match[1].to_sym
|
|
481
|
+
rest = match.post_match
|
|
482
|
+
end
|
|
483
|
+
prefix = value[0, value.length - rest.length]
|
|
484
|
+
propose_modifiers = rest.start_with?(MARKER_MODIFIER) ? !MODIFIERS_LITERAL.include?(last) : rest.empty? && MODIFIERS_DECODING.include?(last)
|
|
485
|
+
completion =
|
|
486
|
+
if propose_modifiers then Completion.new(candidates: modifiers.map { |m| ["#{MARKER_MODIFIER}#{m}:", ExtendedValue.instance.description(m)] })
|
|
487
|
+
else
|
|
488
|
+
case last
|
|
489
|
+
when :file, :path then Completion.new(candidates: [], files: complete.eql?(:folder) ? :folder : :file)
|
|
490
|
+
when :preset then Completion.new(candidates: completion_preset_names(rest))
|
|
491
|
+
when :env then Completion.new(candidates: ENV.keys.sort.map { |k| [k, nil] })
|
|
492
|
+
when :stdin then Completion.new(candidates: STDIN_MODES.map { |m| [m, nil] })
|
|
493
|
+
when *MODIFIERS_DECODING then Completion.new(candidates: [])
|
|
494
|
+
else Completion.new(candidates: [], hint: ExtendedValue.instance.description(last))
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
completion.prefixed(prefix)
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
# Names of presets (with their comment as description), and parameters of the preset typed (`@preset:` takes a dot path)
|
|
501
|
+
# @param value [String] value typed
|
|
502
|
+
# @return [Array<Array(String, String)>]
|
|
503
|
+
def completion_preset_names(value)
|
|
504
|
+
presets.config_presets.flat_map do |name, preset|
|
|
505
|
+
parameters = value.start_with?("#{name}#{DotContainer::SEPARATOR}") ? completion_preset_parameters(name) : []
|
|
506
|
+
comment = completion_description(preset[PresetManager::Key::COMMENT]) if preset.is_a?(Hash)
|
|
507
|
+
[[name, comment]] + parameters.map { |parameter, _| ["#{name}#{DotContainer::SEPARATOR}#{parameter}", nil] }
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
# @param name [String, nil] name of preset
|
|
512
|
+
# @return [Array<Array(String, nil)>] parameters of the preset, empty if it is not a preset
|
|
513
|
+
def completion_preset_parameters(name)
|
|
514
|
+
preset = presets.config_presets[name]
|
|
515
|
+
return [] unless preset.is_a?(Hash)
|
|
516
|
+
preset.keys.map(&:to_s).reject { |k| k.start_with?(PresetManager::Key::META_PREFIX) }.map { |k| [k, nil] }
|
|
287
517
|
end
|
|
288
518
|
|
|
289
519
|
# @param type [String] expected type, e.g. `Hash`
|
|
@@ -319,9 +549,10 @@ module Aspera
|
|
|
319
549
|
end
|
|
320
550
|
|
|
321
551
|
# @param arg_spec [ArgumentSpec] expected argument
|
|
552
|
+
# @param value [String] value typed
|
|
553
|
+
# @param position [Position] command reached
|
|
322
554
|
# @return [Completion] allowed values of the argument, or its type (and keys of its schema) as hint
|
|
323
|
-
def completion_argument(arg_spec)
|
|
324
|
-
return Completion.new(candidates: arg_spec.allowed.map { |v| [v.to_s, nil] }) if arg_spec.allowed
|
|
555
|
+
def completion_argument(arg_spec, value, position)
|
|
325
556
|
type_str =
|
|
326
557
|
case arg_spec.type
|
|
327
558
|
when :identifier then 'identifier'
|
|
@@ -330,7 +561,10 @@ module Aspera
|
|
|
330
561
|
when nil then 'String'
|
|
331
562
|
else arg_spec.type.to_s
|
|
332
563
|
end
|
|
333
|
-
|
|
564
|
+
hint = completion_hint(type_str, arg_spec.schema)
|
|
565
|
+
# Percent selector: lookup of the identifier by a field
|
|
566
|
+
hint = "#{hint} or %<field>:<value>" if arg_spec.type.eql?(:identifier) && !arg_spec.lookup.nil?
|
|
567
|
+
completion_value(value, position, hint: hint, allowed: arg_spec.allowed&.map(&:to_s), complete: arg_spec.complete, extended: !arg_spec.evaluate.eql?(:none))
|
|
334
568
|
end
|
|
335
569
|
|
|
336
570
|
# @param plugin_sym [Symbol] plugin name
|
|
@@ -342,9 +576,9 @@ module Aspera
|
|
|
342
576
|
end
|
|
343
577
|
|
|
344
578
|
# @param text [String, nil] description
|
|
345
|
-
# @return [String, nil] first line, without final period, as displayed by the shell
|
|
579
|
+
# @return [String, nil] first sentence of first line, without final period, as displayed by the shell
|
|
346
580
|
def completion_description(text)
|
|
347
|
-
line = text.to_s.lines.first.to_s.strip.tr("\t", ' ').delete_suffix('.')
|
|
581
|
+
line = text.to_s.lines.first.to_s.strip.tr("\t", ' ').split(REGEX_SENTENCE_END).first.to_s.delete_suffix('.')
|
|
348
582
|
line.empty? ? nil : line
|
|
349
583
|
end
|
|
350
584
|
|
|
@@ -353,7 +587,7 @@ module Aspera
|
|
|
353
587
|
# @param shell [Symbol] One of `COMPLETION_SHELLS`
|
|
354
588
|
def completion_script(shell)
|
|
355
589
|
$stdout.write(File.read(File.join(COMPLETION_FOLDER, "#{Info::CMD_NAME}.#{COMPLETION_SHELLS[shell]}")))
|
|
356
|
-
Process.exit(0)
|
|
590
|
+
::Process.exit(0)
|
|
357
591
|
end
|
|
358
592
|
end
|
|
359
593
|
end
|
data/lib/aspera/cli/context.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../assert'
|
|
7
|
+
require_relative 'mailer'
|
|
8
|
+
require_relative 'secret_finder'
|
|
6
9
|
|
|
7
10
|
module Aspera
|
|
8
11
|
module Cli
|
|
@@ -10,7 +13,7 @@ module Aspera
|
|
|
10
13
|
class Context
|
|
11
14
|
# @type [Array<Symbol>]
|
|
12
15
|
# Members that must be non-nil after bootstrap (validated in #validate)
|
|
13
|
-
MEMBERS = %i[options transfer config formatter persistency man_header presets http_config main_folder mailer secret_finder].freeze
|
|
16
|
+
MEMBERS = %i[options transfer config formatter persistency man_header presets vault http_config main_folder mailer secret_finder].freeze
|
|
14
17
|
# @!attribute [rw] options
|
|
15
18
|
# @return [Parser] the command line options manager
|
|
16
19
|
# @!attribute [rw] transfer
|
|
@@ -25,6 +28,8 @@ module Aspera
|
|
|
25
28
|
# @return [Boolean] whether to display the manual header in plugin help
|
|
26
29
|
# @!attribute [rw] presets
|
|
27
30
|
# @return [PresetManager] manages the YAML config file and preset resolution
|
|
31
|
+
# @!attribute [rw] vault
|
|
32
|
+
# @return [VaultManager] secrets of the vault: `@vault:`, `config vault`, presets
|
|
28
33
|
# @!attribute [rw] http_config
|
|
29
34
|
# @return [Http] manages HTTP/S and TLS runtime options
|
|
30
35
|
# @!attribute [rw] mailer
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'version'
|
|
7
|
+
require_relative '../assert'
|
|
5
8
|
|
|
6
9
|
module Aspera
|
|
7
10
|
module Cli
|
data/lib/aspera/cli/error.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
3
6
|
module Aspera
|
|
4
7
|
module Cli
|
|
5
8
|
# Exit status of the process, by category of error
|
|
@@ -67,6 +70,9 @@ module Aspera
|
|
|
67
70
|
|
|
68
71
|
class NoSuchElement < Error; end
|
|
69
72
|
|
|
73
|
+
# Raised when the condition of option `poll` (`until`) is not met after the last run.
|
|
74
|
+
class PollConditionNotMet < Error; end
|
|
75
|
+
|
|
70
76
|
# Raised when a lookup for a specific entity fails to return exactly one result.
|
|
71
77
|
#
|
|
72
78
|
# Provides a formatted message indicating whether the entity was missing
|