aspera-cli 4.24.1 → 4.25.0.pre
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/CHANGELOG.md +1064 -745
- data/CONTRIBUTING.md +43 -100
- data/README.md +1281 -720
- data/bin/ascli +20 -1
- data/bin/asession +23 -27
- data/lib/aspera/agent/base.rb +10 -21
- data/lib/aspera/agent/connect.rb +2 -3
- data/lib/aspera/agent/desktop.rb +2 -2
- data/lib/aspera/agent/direct.rb +49 -32
- data/lib/aspera/agent/factory.rb +31 -0
- data/lib/aspera/api/aoc.rb +134 -76
- data/lib/aspera/api/cos_node.rb +3 -2
- data/lib/aspera/api/faspex.rb +213 -0
- data/lib/aspera/api/node.rb +107 -94
- data/lib/aspera/ascmd.rb +1 -2
- data/lib/aspera/ascp/installation.rb +73 -58
- data/lib/aspera/ascp/management.rb +119 -23
- data/lib/aspera/assert.rb +39 -11
- data/lib/aspera/cli/error.rb +4 -2
- data/lib/aspera/cli/extended_value.rb +91 -67
- data/lib/aspera/cli/formatter.rb +62 -27
- data/lib/aspera/cli/hints.rb +8 -0
- data/lib/aspera/cli/info.rb +4 -4
- data/lib/aspera/cli/main.rb +76 -84
- data/lib/aspera/cli/manager.rb +352 -248
- data/lib/aspera/cli/plugins/alee.rb +5 -4
- data/lib/aspera/cli/plugins/aoc.rb +175 -195
- data/lib/aspera/cli/plugins/ats.rb +4 -4
- data/lib/aspera/cli/plugins/base.rb +343 -0
- data/lib/aspera/cli/plugins/basic_auth.rb +45 -0
- data/lib/aspera/cli/plugins/config.rb +283 -269
- data/lib/aspera/cli/plugins/console.rb +27 -22
- data/lib/aspera/cli/plugins/cos.rb +3 -3
- data/lib/aspera/cli/plugins/factory.rb +78 -0
- data/lib/aspera/cli/plugins/faspex.rb +49 -46
- data/lib/aspera/cli/plugins/faspex5.rb +113 -225
- data/lib/aspera/cli/plugins/faspio.rb +19 -18
- data/lib/aspera/cli/plugins/httpgw.rb +14 -13
- data/lib/aspera/cli/plugins/node.rb +162 -149
- data/lib/aspera/cli/plugins/oauth.rb +48 -0
- data/lib/aspera/cli/plugins/orchestrator.rb +129 -45
- data/lib/aspera/cli/plugins/preview.rb +30 -50
- data/lib/aspera/cli/plugins/server.rb +21 -21
- data/lib/aspera/cli/plugins/shares.rb +45 -47
- data/lib/aspera/cli/sync_actions.rb +50 -39
- data/lib/aspera/cli/transfer_agent.rb +35 -49
- data/lib/aspera/cli/transfer_progress.rb +6 -6
- data/lib/aspera/cli/version.rb +3 -3
- data/lib/aspera/cli/wizard.rb +70 -55
- data/lib/aspera/colors.rb +6 -0
- data/lib/aspera/command_line_builder.rb +59 -61
- data/lib/aspera/command_line_converter.rb +2 -1
- data/lib/aspera/coverage.rb +2 -2
- data/lib/aspera/data_repository.rb +1 -1
- data/lib/aspera/environment.rb +51 -41
- data/lib/aspera/faspex_gw.rb +7 -5
- data/lib/aspera/faspex_postproc.rb +1 -1
- data/lib/aspera/keychain/factory.rb +1 -2
- data/lib/aspera/keychain/macos_security.rb +1 -1
- data/lib/aspera/log.rb +37 -9
- data/lib/aspera/markdown.rb +31 -0
- data/lib/aspera/nagios.rb +7 -6
- data/lib/aspera/oauth/base.rb +25 -28
- data/lib/aspera/oauth/factory.rb +9 -9
- data/lib/aspera/oauth/url_json.rb +2 -1
- data/lib/aspera/oauth/web.rb +2 -2
- data/lib/aspera/preview/file_types.rb +23 -37
- data/lib/aspera/products/connect.rb +7 -6
- data/lib/aspera/products/desktop.rb +1 -4
- data/lib/aspera/products/other.rb +9 -1
- data/lib/aspera/products/transferd.rb +0 -1
- data/lib/aspera/rest.rb +168 -113
- data/lib/aspera/rest_error_analyzer.rb +4 -4
- data/lib/aspera/ssh.rb +7 -4
- data/lib/aspera/ssl.rb +41 -0
- data/lib/aspera/sync/args.schema.yaml +46 -3
- data/lib/aspera/sync/conf.schema.yaml +307 -123
- data/lib/aspera/sync/database.rb +2 -1
- data/lib/aspera/sync/operations.rb +135 -79
- data/lib/aspera/temp_file_manager.rb +17 -5
- data/lib/aspera/transfer/error.rb +16 -7
- data/lib/aspera/transfer/parameters.rb +35 -22
- data/lib/aspera/transfer/resumer.rb +74 -0
- data/lib/aspera/transfer/spec.rb +5 -5
- data/lib/aspera/transfer/spec.schema.yaml +170 -59
- data/lib/aspera/transfer/spec_doc.rb +49 -43
- data/lib/aspera/uri_reader.rb +2 -2
- data/lib/aspera/web_auth.rb +6 -6
- data/lib/transferd_pb.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +26 -11
- metadata.gz.sig +0 -0
- data/lib/aspera/cli/basic_auth_plugin.rb +0 -43
- data/lib/aspera/cli/plugin.rb +0 -333
- data/lib/aspera/cli/plugin_factory.rb +0 -81
- data/lib/aspera/resumer.rb +0 -77
- data/lib/aspera/transfer/error_info.rb +0 -91
data/lib/aspera/cli/main.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'aspera/cli/manager'
|
|
|
4
4
|
require 'aspera/cli/formatter'
|
|
5
5
|
require 'aspera/cli/plugins/config'
|
|
6
6
|
require 'aspera/cli/extended_value'
|
|
7
|
-
require 'aspera/cli/
|
|
7
|
+
require 'aspera/cli/plugins/factory'
|
|
8
8
|
require 'aspera/cli/transfer_agent'
|
|
9
9
|
require 'aspera/cli/version'
|
|
10
10
|
require 'aspera/cli/info'
|
|
@@ -46,29 +46,13 @@ module Aspera
|
|
|
46
46
|
STATUS_FIELD = 'status'
|
|
47
47
|
COMMAND_CONFIG = :config
|
|
48
48
|
COMMAND_HELP = :help
|
|
49
|
-
#
|
|
49
|
+
# Types that go to result of type = text
|
|
50
50
|
SCALAR_TYPES = [String, Integer, Symbol].freeze
|
|
51
51
|
USER_INTERFACES = %i[text graphical].freeze
|
|
52
52
|
|
|
53
53
|
private_constant :COMMAND_CONFIG, :COMMAND_HELP, :SCALAR_TYPES, :USER_INTERFACES
|
|
54
54
|
|
|
55
55
|
class << self
|
|
56
|
-
# early debug for parser
|
|
57
|
-
# Note: does not accept shortcuts
|
|
58
|
-
def early_debug_setup(argv)
|
|
59
|
-
Log.instance.program_name = Info::CMD_NAME
|
|
60
|
-
argv.each do |arg|
|
|
61
|
-
case arg
|
|
62
|
-
when '--' then break
|
|
63
|
-
when /^--log-level=(.*)/ then Log.instance.level = Regexp.last_match(1).to_sym
|
|
64
|
-
when /^--logger=(.*)/ then Log.instance.logger_type = Regexp.last_match(1).to_sym
|
|
65
|
-
end
|
|
66
|
-
rescue => e
|
|
67
|
-
$stderr.puts("Error: #{e}") # rubocop:disable Style/StderrPuts
|
|
68
|
-
Process.exit(1)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
56
|
def result_special(how); {type: :special, data: how}; end
|
|
73
57
|
|
|
74
58
|
# Expect some list, but nothing to display
|
|
@@ -81,13 +65,13 @@ module Aspera
|
|
|
81
65
|
# @param status [String] The status
|
|
82
66
|
def result_status(status); return {type: :status, data: status}; end
|
|
83
67
|
|
|
84
|
-
#
|
|
68
|
+
# Text result coming from command result
|
|
85
69
|
def result_text(data); return {type: :text, data: data}; end
|
|
86
70
|
|
|
87
71
|
def result_success; return result_status('complete'); end
|
|
88
72
|
|
|
89
73
|
# Process statuses of finished transfer sessions
|
|
90
|
-
# raise exception if there is one error
|
|
74
|
+
# @raise exception if there is one error
|
|
91
75
|
# else returns an empty status
|
|
92
76
|
def result_transfer(statuses)
|
|
93
77
|
worst = TransferAgent.session_status(statuses)
|
|
@@ -98,10 +82,10 @@ module Aspera
|
|
|
98
82
|
# Used when one command executes several transfer jobs (each job being possibly multi session)
|
|
99
83
|
# @param status_table [Array] [{STATUS_FIELD=>[status array],...},...]
|
|
100
84
|
# @return a status object suitable as command result
|
|
101
|
-
#
|
|
85
|
+
# Each element has a key STATUS_FIELD which contains the result of possibly multiple sessions
|
|
102
86
|
def result_transfer_multiple(status_table)
|
|
103
87
|
global_status = :success
|
|
104
|
-
#
|
|
88
|
+
# Transform status array into string and find if there was problem
|
|
105
89
|
status_table.each do |item|
|
|
106
90
|
worst = TransferAgent.session_status(item[STATUS_FIELD])
|
|
107
91
|
global_status = worst unless worst.eql?(:success)
|
|
@@ -153,7 +137,7 @@ module Aspera
|
|
|
153
137
|
end
|
|
154
138
|
end
|
|
155
139
|
|
|
156
|
-
#
|
|
140
|
+
# Minimum initialization, no exception raised
|
|
157
141
|
def initialize(argv)
|
|
158
142
|
@argv = argv
|
|
159
143
|
Log.dump(:argv, @argv, level: :trace2)
|
|
@@ -163,16 +147,16 @@ module Aspera
|
|
|
163
147
|
@context = Context.new
|
|
164
148
|
end
|
|
165
149
|
|
|
166
|
-
#
|
|
150
|
+
# This is the main function called by initial script just after constructor
|
|
167
151
|
def process_command_line
|
|
168
|
-
#
|
|
152
|
+
# Catch exception information , if any
|
|
169
153
|
exception_info = nil
|
|
170
|
-
#
|
|
154
|
+
# False if command shall not be executed (e.g. --show-config)
|
|
171
155
|
execute_command = true
|
|
172
|
-
#
|
|
156
|
+
# Catch exceptions
|
|
173
157
|
begin
|
|
174
158
|
init_agents_options_plugins
|
|
175
|
-
#
|
|
159
|
+
# Help requested without command ? (plugins must be known here)
|
|
176
160
|
show_usage if @option_help && @context.options.command_or_arg_empty?
|
|
177
161
|
generate_bash_completion if @bash_completion
|
|
178
162
|
@context.config.periodic_check_newer_gem_version
|
|
@@ -180,35 +164,35 @@ module Aspera
|
|
|
180
164
|
if @option_show_config && @context.options.command_or_arg_empty?
|
|
181
165
|
COMMAND_CONFIG
|
|
182
166
|
else
|
|
183
|
-
@context.options.get_next_command(
|
|
167
|
+
@context.options.get_next_command(Plugins::Factory.instance.plugin_list.unshift(COMMAND_HELP))
|
|
184
168
|
end
|
|
185
|
-
#
|
|
169
|
+
# Command will not be executed, but we need manual
|
|
186
170
|
@context.options.fail_on_missing_mandatory = false if @option_help || @option_show_config
|
|
187
|
-
#
|
|
171
|
+
# Main plugin is not dynamically instantiated
|
|
188
172
|
case command_sym
|
|
189
173
|
when COMMAND_HELP
|
|
190
174
|
show_usage
|
|
191
175
|
when COMMAND_CONFIG
|
|
192
176
|
command_plugin = @context.config
|
|
193
177
|
else
|
|
194
|
-
#
|
|
178
|
+
# Get plugin, set options, etc
|
|
195
179
|
command_plugin = get_plugin_instance_with_options(command_sym)
|
|
196
|
-
#
|
|
180
|
+
# Parse plugin specific options
|
|
197
181
|
@context.options.parse_options!
|
|
198
182
|
end
|
|
199
|
-
#
|
|
183
|
+
# Help requested for current plugin
|
|
200
184
|
show_usage(all: false) if @option_help
|
|
201
185
|
if @option_show_config
|
|
202
186
|
@context.formatter.display_results(type: :single_object, data: @context.options.known_options(only_defined: true).stringify_keys)
|
|
203
187
|
execute_command = false
|
|
204
188
|
end
|
|
205
|
-
#
|
|
189
|
+
# Locking for single execution (only after "per plugin" option, in case lock port is there)
|
|
206
190
|
lock_port = @context.options.get_option(:lock_port)
|
|
207
191
|
if !lock_port.nil?
|
|
208
192
|
begin
|
|
209
|
-
#
|
|
193
|
+
# No need to close later, will be freed on process exit. must save in member else it is garbage collected
|
|
210
194
|
Log.log.debug{"Opening lock port #{lock_port}"}
|
|
211
|
-
#
|
|
195
|
+
# Loopback address, could also be 'localhost'
|
|
212
196
|
@tcp_server = TCPServer.new('127.0.0.1', lock_port)
|
|
213
197
|
rescue StandardError => e
|
|
214
198
|
execute_command = false
|
|
@@ -221,15 +205,16 @@ module Aspera
|
|
|
221
205
|
Log.log.debug{"Wrote pid #{Process.pid} to #{pid_file}"}
|
|
222
206
|
at_exit{File.delete(pid_file)}
|
|
223
207
|
end
|
|
224
|
-
#
|
|
208
|
+
# Execute and display (if not exclusive execution)
|
|
225
209
|
@context.formatter.display_results(**command_plugin.execute_action) if execute_command
|
|
226
|
-
#
|
|
210
|
+
# Save config file if command modified it
|
|
227
211
|
@context.config.save_config_file_if_needed
|
|
228
|
-
#
|
|
212
|
+
# Finish
|
|
229
213
|
@context.transfer.shutdown
|
|
230
214
|
rescue Net::SSH::AuthenticationFailed => e; exception_info = {e: e, t: 'SSH', security: true}
|
|
231
215
|
rescue OpenSSL::SSL::SSLError => e; exception_info = {e: e, t: 'SSL'}
|
|
232
216
|
rescue Cli::BadArgument => e; exception_info = {e: e, t: 'Argument', usage: true}
|
|
217
|
+
rescue Cli::MissingArgument => e; exception_info = {e: e, t: 'Missing', usage: true}
|
|
233
218
|
rescue Cli::BadIdentifier => e; exception_info = {e: e, t: 'Identifier'}
|
|
234
219
|
rescue Cli::Error => e; exception_info = {e: e, t: 'Tool', usage: true}
|
|
235
220
|
rescue Transfer::Error => e; exception_info = {e: e, t: 'Transfer'}
|
|
@@ -238,12 +223,13 @@ module Aspera
|
|
|
238
223
|
rescue StandardError => e; exception_info = {e: e, t: "Other(#{e.class.name})", debug: true}
|
|
239
224
|
rescue Interrupt => e; exception_info = {e: e, t: 'Interruption', debug: true}
|
|
240
225
|
end
|
|
241
|
-
#
|
|
226
|
+
# Cleanup file list files
|
|
242
227
|
TempFileManager.instance.cleanup
|
|
243
228
|
# 1- processing of error condition
|
|
244
229
|
unless exception_info.nil?
|
|
245
230
|
Log.log.warn(exception_info[:e].message) if Log.instance.logger_type.eql?(:syslog) && exception_info[:security]
|
|
246
231
|
@context.formatter.display_message(:error, "#{Formatter::ERROR_FLASH} #{exception_info[:t]}: #{exception_info[:e].message}")
|
|
232
|
+
Log.log.debug{(['Backtrace:'] + exception_info[:e].backtrace).join("\n")} if exception_info[:debug]
|
|
247
233
|
@context.formatter.display_message(:error, 'Use option -h to get help.') if exception_info[:usage]
|
|
248
234
|
# Is that a known error condition with proposal for remediation ?
|
|
249
235
|
Hints.hint_for(exception_info[:e], @context.formatter)
|
|
@@ -252,15 +238,15 @@ module Aspera
|
|
|
252
238
|
if execute_command || @option_show_config
|
|
253
239
|
@context.options.final_errors.each do |msg|
|
|
254
240
|
@context.formatter.display_message(:error, "#{Formatter::ERROR_FLASH} Argument: #{msg}")
|
|
255
|
-
#
|
|
241
|
+
# Add code as exception if there is not already an error
|
|
256
242
|
exception_info = {e: Exception.new(msg), t: 'UnusedArg'} if exception_info.nil?
|
|
257
243
|
end
|
|
258
244
|
end
|
|
259
245
|
# 3- in case of error, fail the process status
|
|
260
246
|
unless exception_info.nil?
|
|
261
|
-
#
|
|
247
|
+
# Show stack trace in debug mode
|
|
262
248
|
raise exception_info[:e] if Log.log.debug?
|
|
263
|
-
#
|
|
249
|
+
# Else give hint and exit
|
|
264
250
|
@context.formatter.display_message(:error, 'Use --log-level=debug to get more details.') if exception_info[:debug]
|
|
265
251
|
Process.exit(1)
|
|
266
252
|
end
|
|
@@ -269,24 +255,24 @@ module Aspera
|
|
|
269
255
|
|
|
270
256
|
def init_agents_options_plugins
|
|
271
257
|
init_agents_and_options
|
|
272
|
-
#
|
|
273
|
-
|
|
258
|
+
# Find plugins, shall be after parse! ?
|
|
259
|
+
Plugins::Factory.instance.add_plugins_from_lookup_folders
|
|
274
260
|
end
|
|
275
261
|
|
|
276
262
|
def show_usage(all: true, exit: true)
|
|
277
|
-
#
|
|
263
|
+
# Display main plugin options (+config)
|
|
278
264
|
@context.formatter.display_message(:error, @context.options.parser)
|
|
279
265
|
if all
|
|
280
266
|
@context.only_manual
|
|
281
|
-
#
|
|
282
|
-
|
|
283
|
-
#
|
|
267
|
+
# List plugins that have a "require" field, i.e. all but main plugin
|
|
268
|
+
Plugins::Factory.instance.plugin_list.each do |plugin_name_sym|
|
|
269
|
+
# Config was already included in the global options
|
|
284
270
|
next if plugin_name_sym.eql?(COMMAND_CONFIG)
|
|
285
|
-
#
|
|
271
|
+
# Override main option parser with a brand new, to avoid having global options
|
|
286
272
|
@context.options = Manager.new(Info::CMD_NAME)
|
|
287
|
-
@context.options.parser.banner = '' #
|
|
273
|
+
@context.options.parser.banner = '' # Remove default banner
|
|
288
274
|
get_plugin_instance_with_options(plugin_name_sym)
|
|
289
|
-
#
|
|
275
|
+
# Display generated help for plugin options
|
|
290
276
|
@context.formatter.display_message(:error, @context.options.parser.help)
|
|
291
277
|
end
|
|
292
278
|
end
|
|
@@ -297,34 +283,33 @@ module Aspera
|
|
|
297
283
|
|
|
298
284
|
# This can throw exception if there is a problem with the environment, needs to be caught by execute method
|
|
299
285
|
def init_agents_and_options
|
|
300
|
-
#
|
|
286
|
+
# Create formatter, in case there is an exception, it is used to display.
|
|
301
287
|
@context.formatter = Formatter.new
|
|
302
|
-
#
|
|
288
|
+
# Create command line manager with arguments
|
|
303
289
|
@context.options = Manager.new(Info::CMD_NAME, @argv)
|
|
304
|
-
#
|
|
290
|
+
# Formatter adds options
|
|
305
291
|
@context.formatter.declare_options(@context.options)
|
|
306
|
-
|
|
307
|
-
# compare $0 with expected name
|
|
292
|
+
# Compare $0 with expected name
|
|
308
293
|
current_prog_name = File.basename($PROGRAM_NAME)
|
|
309
294
|
@context.formatter.display_message(
|
|
310
295
|
:error,
|
|
311
296
|
"#{Formatter::WARNING_FLASH} Please use '#{Info::CMD_NAME}' instead of '#{current_prog_name}'"
|
|
312
297
|
) unless current_prog_name.eql?(Info::CMD_NAME)
|
|
313
|
-
#
|
|
298
|
+
# Declare and parse global options
|
|
314
299
|
declare_global_options
|
|
315
|
-
#
|
|
300
|
+
# Do not display config commands if help is asked
|
|
316
301
|
@context.man_header = false
|
|
317
|
-
#
|
|
302
|
+
# The Config plugin adds the @preset parser, so declare before TransferAgent which may use it
|
|
318
303
|
@context.config = Plugins::Config.new(context: @context)
|
|
319
304
|
@context.man_header = true
|
|
320
|
-
#
|
|
305
|
+
# Data persistency is set in config
|
|
321
306
|
Aspera.assert(@context.persistency){'missing persistency object'}
|
|
322
|
-
#
|
|
307
|
+
# The TransferAgent plugin may use the @preset parser
|
|
323
308
|
@context.transfer = TransferAgent.new(@context.options, @context.config)
|
|
324
|
-
#
|
|
309
|
+
# Add commands for config plugin after all options have been added
|
|
325
310
|
@context.config.add_manual_header(false)
|
|
326
311
|
@context.validate
|
|
327
|
-
#
|
|
312
|
+
# Set banner when all environment is created so that additional extended value modifiers are known, e.g. @preset
|
|
328
313
|
@context.options.parser.banner = app_banner
|
|
329
314
|
end
|
|
330
315
|
|
|
@@ -362,48 +347,55 @@ module Aspera
|
|
|
362
347
|
END_OF_BANNER
|
|
363
348
|
end
|
|
364
349
|
|
|
365
|
-
#
|
|
350
|
+
# Define header for manual
|
|
366
351
|
def declare_global_options
|
|
367
352
|
Log.log.debug('declare_global_options')
|
|
368
|
-
@context.options.declare(:help, 'Show this message',
|
|
369
|
-
@context.options.declare(:bash_comp, 'Generate bash completion for command',
|
|
370
|
-
@context.options.declare(:show_config, 'Display parameters used for the provided action',
|
|
371
|
-
@context.options.declare(:version, 'Display version',
|
|
353
|
+
@context.options.declare(:help, 'Show this message', allowed: Allowed::TYPES_NONE, short: 'h'){@option_help = true}
|
|
354
|
+
@context.options.declare(:bash_comp, 'Generate bash completion for command', allowed: Allowed::TYPES_NONE){@bash_completion = true}
|
|
355
|
+
@context.options.declare(:show_config, 'Display parameters used for the provided action', allowed: Allowed::TYPES_NONE){@option_show_config = true}
|
|
356
|
+
@context.options.declare(:version, 'Display version', allowed: Allowed::TYPES_NONE, short: 'v'){@context.formatter.display_message(:data, Cli::VERSION); Process.exit(0)} # rubocop:disable Style/Semicolon
|
|
372
357
|
@context.options.declare(
|
|
373
358
|
:ui, 'Method to start browser',
|
|
374
|
-
|
|
359
|
+
allowed: USER_INTERFACES,
|
|
375
360
|
handler: {o: Environment.instance, m: :url_method}
|
|
376
361
|
)
|
|
377
362
|
@context.options.declare(
|
|
378
363
|
:invalid_characters, 'Replacement character and invalid filename characters',
|
|
379
364
|
handler: {o: Environment.instance, m: :file_illegal_characters}
|
|
380
365
|
)
|
|
381
|
-
@context.options.declare(:log_level, 'Log level',
|
|
382
|
-
@context.options.declare(:log_format, 'Log formatter',
|
|
383
|
-
@context.options.declare(:logger, 'Logging method',
|
|
384
|
-
@context.options.declare(:lock_port, 'Prevent dual execution of a command, e.g. in cron',
|
|
385
|
-
@context.options.declare(:once_only, 'Process only new items (some commands)',
|
|
386
|
-
@context.options.declare(:log_secrets, 'Show passwords in logs',
|
|
387
|
-
@context.options.declare(:clean_temp, 'Cleanup temporary files on exit',
|
|
388
|
-
@context.options.declare(:
|
|
389
|
-
|
|
366
|
+
@context.options.declare(:log_level, 'Log level', allowed: Log::LEVELS, handler: {o: Log.instance, m: :level})
|
|
367
|
+
@context.options.declare(:log_format, 'Log formatter', allowed: [Proc, Logger::Formatter, String], handler: {o: Log.instance, m: :formatter})
|
|
368
|
+
@context.options.declare(:logger, 'Logging method', allowed: Log::LOG_TYPES, handler: {o: Log.instance, m: :logger_type})
|
|
369
|
+
@context.options.declare(:lock_port, 'Prevent dual execution of a command, e.g. in cron', allowed: Allowed::TYPES_INTEGER)
|
|
370
|
+
@context.options.declare(:once_only, 'Process only new items (some commands)', allowed: Allowed::TYPES_BOOLEAN, default: false)
|
|
371
|
+
@context.options.declare(:log_secrets, 'Show passwords in logs', allowed: Allowed::TYPES_BOOLEAN, handler: {o: SecretHider.instance, m: :log_secrets})
|
|
372
|
+
@context.options.declare(:clean_temp, 'Cleanup temporary files on exit', allowed: Allowed::TYPES_BOOLEAN, handler: {o: TempFileManager.instance, m: :cleanup_on_exit})
|
|
373
|
+
@context.options.declare(:temp_folder, 'Temporary folder', handler: {o: TempFileManager.instance, m: :global_temp})
|
|
374
|
+
@context.options.declare(:pid_file, 'Write process identifier to file, delete on exit')
|
|
375
|
+
@context.options.declare(
|
|
376
|
+
:parser, 'Default parser for structured parameters and options',
|
|
377
|
+
handler: {o: ExtendedValue.instance, m: :default_decoder},
|
|
378
|
+
allowed: ExtendedValue::DEFAULT_DECODERS,
|
|
379
|
+
default: ExtendedValue::DEFAULT_DECODERS.first
|
|
380
|
+
)
|
|
381
|
+
# Parse declared options
|
|
390
382
|
@context.options.parse_options!
|
|
391
383
|
end
|
|
392
384
|
|
|
393
385
|
# @return the plugin instance, based on name
|
|
394
|
-
#
|
|
386
|
+
# Also loads the plugin options, and default values from conf file
|
|
395
387
|
# @param plugin_name_sym : symbol for plugin name
|
|
396
388
|
def get_plugin_instance_with_options(plugin_name_sym)
|
|
397
389
|
Log.log.debug{"get_plugin_instance_with_options(#{plugin_name_sym})"}
|
|
398
|
-
#
|
|
390
|
+
# Load default params only if no param already loaded before plugin instantiation
|
|
399
391
|
@context.config.add_plugin_default_preset(plugin_name_sym)
|
|
400
|
-
command_plugin =
|
|
392
|
+
command_plugin = Plugins::Factory.instance.create(plugin_name_sym, context: @context)
|
|
401
393
|
return command_plugin
|
|
402
394
|
end
|
|
403
395
|
|
|
404
396
|
def generate_bash_completion
|
|
405
397
|
if @context.options.get_next_argument('', multiple: true, mandatory: false).nil?
|
|
406
|
-
|
|
398
|
+
Plugins::Factory.instance.plugin_list.each{ |p| puts p}
|
|
407
399
|
else
|
|
408
400
|
Log.log.warn('only first level completion so far')
|
|
409
401
|
end
|