Skip to content

Commit e65bd90

Browse files
rename class Main to Runner
Signed-off-by: Laurent Martin <laurent.martin.l@gmail.com>
1 parent 21863a1 commit e65bd90

7 files changed

Lines changed: 61 additions & 55 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The `aspera-cli` architecture is designed to be modular and extensible.
7272

7373
- **Entry Point**:
7474

75-
`lib/aspera/cli/main.rb` contains the core CLI startup logic.
75+
`lib/aspera/cli/runner.rb` contains the core CLI startup logic.
7676

7777
- **Plugins**:
7878

bin/ascli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ end
3131

3232
require 'aspera/coverage'
3333
require 'aspera/environment'
34-
require 'aspera/cli/main'
34+
require 'aspera/cli/runner'
3535
Aspera::Environment.instance.fix_home
36-
Aspera::Cli::Main.new(ARGV).process_command_line
36+
Aspera::Cli::Runner.new(ARGV).process_command_line

build/lib/doc_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
require 'aspera/agent/factory'
1111
require 'aspera/cli/plugins/factory'
1212
require 'aspera/cli/plugins/config'
13-
require 'aspera/cli/main'
1413
require 'aspera/schema/documentation'
1514
require 'aspera/schema/registry'
1615
require 'aspera/sync/operations'

docs/ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The main executable script that:
4646
#!/usr/bin/env ruby
4747
Encoding.default_internal = Encoding::UTF_8
4848
Encoding.default_external = Encoding::UTF_8
49-
require 'aspera/cli/main'
50-
Aspera::Cli::Main.new(ARGV).process_command_line
49+
require 'aspera/cli/runner'
50+
Aspera::Cli::Runner.new(ARGV).process_command_line
5151
```
5252

5353
#### 2.2 CLI Manager

lib/aspera/cli/context.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
require 'aspera/assert'
4+
5+
module Aspera
6+
module Cli
7+
# Global objects shared with plugins
8+
class Context
9+
# @type [Array<Symbol>]
10+
MEMBERS = %i[options transfer config formatter persistency man_header].freeze
11+
# @!attribute [rw] options
12+
# @return [Manager] the command line options manager
13+
# @!attribute [rw] transfer
14+
# @return [TransferAgent] the transfer agent, used by transfer plugins
15+
# @!attribute [rw] config
16+
# @return [Plugins::Config] the configuration plugin, used by plugins to get configuration values and presets
17+
# @!attribute [rw] formatter
18+
# @return [Formatter] the formatter, used by plugins to display results and messages
19+
# @!attribute [rw] persistency
20+
# @return [Object] # whatever the type is
21+
# @!attribute [rw] man_header
22+
# @return [Boolean] whether to display the manual header in plugin help
23+
attr_accessor(*MEMBERS)
24+
25+
# Initialize all members to nil, so that they are defined and can be validated later
26+
# @return [nil]
27+
def initialize
28+
MEMBERS.each{ |i| instance_variable_set(:"@#{i}", nil)}
29+
end
30+
31+
# Validate that all members are set, raise exception if not
32+
# @raise [Aspera::AssertionError] if any member is not set
33+
# @return [nil]
34+
def validate
35+
MEMBERS.each do |i|
36+
Aspera.assert(instance_variable_defined?(:"@#{i}"))
37+
Aspera.assert(!instance_variable_get(:"@#{i}").nil?)
38+
end
39+
end
40+
41+
# Check if the context is in manual-only mode
42+
# @return [Boolean] true if in manual-only mode
43+
def only_manual?
44+
transfer.eql?(:only_manual)
45+
end
46+
47+
# Set the context to manual-only mode
48+
# @return [Symbol] :only_manual
49+
def only_manual!
50+
@transfer = :only_manual
51+
end
52+
end
53+
end
54+
end

lib/aspera/cli/runner.rb

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# frozen_string_literal: true
22

3+
require 'aspera/cli/context'
34
require 'aspera/cli/manager'
45
require 'aspera/cli/formatter'
6+
require 'aspera/cli/plugins/factory'
57
require 'aspera/cli/plugins/config'
68
require 'aspera/cli/extended_value'
7-
require 'aspera/cli/plugins/factory'
89
require 'aspera/cli/transfer_agent'
910
require 'aspera/cli/version'
1011
require 'aspera/cli/info'
@@ -20,53 +21,6 @@
2021

2122
module Aspera
2223
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-
7024
# The main CLI class
7125
class Runner
7226
# Plugins store transfer result using this key and use result_transfer_multiple()

spec/aspera-cli_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Aspera::Log.instance.logger_type = :stderr
88
require 'aspera/coverage'
99
require 'aspera/transfer/uri'
10-
require 'aspera/cli/main'
1110
require 'aspera/ascmd'
1211
require 'aspera/assert'
1312
require 'aspera/ssh'

0 commit comments

Comments
 (0)