|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
| 3 | +require 'aspera/cli/context' |
3 | 4 | require 'aspera/cli/manager' |
4 | 5 | require 'aspera/cli/formatter' |
| 6 | +require 'aspera/cli/plugins/factory' |
5 | 7 | require 'aspera/cli/plugins/config' |
6 | 8 | require 'aspera/cli/extended_value' |
7 | | -require 'aspera/cli/plugins/factory' |
8 | 9 | require 'aspera/cli/transfer_agent' |
9 | 10 | require 'aspera/cli/version' |
10 | 11 | require 'aspera/cli/info' |
|
20 | 21 |
|
21 | 22 | module Aspera |
22 | 23 | module Cli |
23 | | - # Global objects shared with plugins |
24 | | - class Context |
25 | | - # @type [Array<Symbol>] |
26 | | - MEMBERS = %i[options transfer config formatter persistency man_header].freeze |
27 | | - # @!attribute [rw] options |
28 | | - # @return [Manager] the command line options manager |
29 | | - # @!attribute [rw] transfer |
30 | | - # @return [TransferAgent] the transfer agent, used by transfer plugins |
31 | | - # @!attribute [rw] config |
32 | | - # @return [Plugins::Config] the configuration plugin, used by plugins to get configuration values and presets |
33 | | - # @!attribute [rw] formatter |
34 | | - # @return [Formatter] the formatter, used by plugins to display results and messages |
35 | | - # @!attribute [rw] persistency |
36 | | - # @return [Object] # whatever the type is |
37 | | - # @!attribute [rw] man_header |
38 | | - # @return [Boolean] whether to display the manual header in plugin help |
39 | | - attr_accessor(*MEMBERS) |
40 | | - |
41 | | - # Initialize all members to nil, so that they are defined and can be validated later |
42 | | - # @return [nil] |
43 | | - def initialize |
44 | | - MEMBERS.each{ |i| instance_variable_set(:"@#{i}", nil)} |
45 | | - end |
46 | | - |
47 | | - # Validate that all members are set, raise exception if not |
48 | | - # @raise [Aspera::AssertionError] if any member is not set |
49 | | - # @return [nil] |
50 | | - def validate |
51 | | - MEMBERS.each do |i| |
52 | | - Aspera.assert(instance_variable_defined?(:"@#{i}")) |
53 | | - Aspera.assert(!instance_variable_get(:"@#{i}").nil?) |
54 | | - end |
55 | | - end |
56 | | - |
57 | | - # Check if the context is in manual-only mode |
58 | | - # @return [Boolean] true if in manual-only mode |
59 | | - def only_manual? |
60 | | - transfer.eql?(:only_manual) |
61 | | - end |
62 | | - |
63 | | - # Set the context to manual-only mode |
64 | | - # @return [Symbol] :only_manual |
65 | | - def only_manual! |
66 | | - @transfer = :only_manual |
67 | | - end |
68 | | - end |
69 | | - |
70 | 24 | # The main CLI class |
71 | 25 | class Runner |
72 | 26 | # Plugins store transfer result using this key and use result_transfer_multiple() |
|
0 commit comments