44module AutoHCK
55 # class CLI
66 class CLI
7- attr_reader :common , :install , :test , :mode
7+ attr_reader :install , :mode
8+ attr_accessor :common , :test
89
910 def initialize
1011 @common = CommonOptions . new
@@ -20,8 +21,15 @@ def initialize
2021 end
2122
2223 # class CommonOptions
23- class CommonOptions
24- attr_accessor :verbose , :config , :client_world_net , :id , :share_on_host_path , :workspace_path
24+ class CommonOptions < T ::Struct
25+ include T ::Sig
26+
27+ prop :verbose , T ::Boolean , default : false
28+ prop :config , T . nilable ( String )
29+ prop :client_world_net , T ::Boolean , default : false
30+ prop :id , T . nilable ( Integer ) , default : 2
31+ prop :share_on_host_path , T . nilable ( String )
32+ prop :workspace_path , T . nilable ( String )
2533
2634 def create_parser ( sub_parser )
2735 OptionParser . new do |parser |
@@ -40,12 +48,6 @@ def create_parser(sub_parser)
4048
4149 # rubocop:disable Metrics/MethodLength
4250 def define_options ( parser )
43- @verbose = false
44- @config = nil
45- @client_world_net = false
46- @id = 2
47- @share_on_host_path = nil
48-
4951 parser . on ( '--share-on-host-path <path>' , String ,
5052 'For using Transfer Network specify the directory to share on host machine' ) do |share_on_host_path |
5153 @share_on_host_path = share_on_host_path
@@ -77,15 +79,30 @@ def define_options(parser)
7779 'Internal use only' ,
7880 &method ( :workspace_path= ) )
7981 end
80- # rubocop:enable Metrics/MethodLength
8182 end
8283
8384 # class TestOptions
84- class TestOptions
85- attr_accessor :platform , :drivers , :driver_path , :commit , :svvp , :dump ,
86- :gthb_context_prefix , :gthb_context_suffix , :playlist , :select_test_names ,
87- :reject_test_names , :reject_report_sections , :boot_device ,
88- :allow_test_duplication , :manual , :package_with_playlist
85+ class TestOptions < T ::Struct
86+ include T ::Sig
87+
88+ prop :platform , T . nilable ( String )
89+ prop :drivers , T . nilable ( T ::Array [ String ] )
90+ prop :driver_path , T . nilable ( String )
91+ prop :commit , T . nilable ( String )
92+ prop :svvp , T . nilable ( T ::Boolean )
93+ prop :dump , T . nilable ( T ::Boolean )
94+ prop :gthb_context_prefix , T . nilable ( String )
95+ prop :gthb_context_suffix , T . nilable ( String )
96+ prop :playlist , T . nilable ( String )
97+ prop :select_test_names , T . nilable ( String )
98+ prop :reject_test_names , T . nilable ( String )
99+ prop :reject_report_sections , T . nilable ( T ::Array [ String ] ) , default : [ ]
100+ prop :boot_device , T . nilable ( String )
101+ prop :allow_test_duplication , T . nilable ( T ::Boolean )
102+ prop :manual , T . nilable ( T ::Boolean )
103+ prop :package_with_playlist , T . nilable ( T ::Boolean )
104+ prop :session , T . nilable ( String )
105+ prop :latest_session , T . nilable ( T ::Boolean )
89106
90107 def create_parser
91108 OptionParser . new do |parser |
@@ -99,8 +116,7 @@ def create_parser
99116 end
100117 end
101118
102- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
103- def define_options ( parser )
119+ def define_options ( parser ) # rubocop:disable Metrics/AbcSize
104120 @reject_report_sections = [ ]
105121
106122 parser . on ( '-p' , '--platform <platform_name>' , String ,
@@ -179,13 +195,28 @@ def define_options(parser)
179195 parser . on ( '--package-with-playlist' , TrueClass ,
180196 'Load playlist into HLKX project package' ,
181197 &method ( :package_with_playlist= ) )
198+
199+ parser . on ( '--session <path>' , String ,
200+ 'Load session from workspace' ,
201+ &method ( :session= ) )
202+
203+ parser . on ( '--latest-session' , TrueClass ,
204+ 'Load previous session' ,
205+ &method ( :latest_session= ) )
182206 end
183- # rubocop:enable Metrics/AbcSize, Metrics/ MethodLength
207+ # rubocop:enable Metrics/MethodLength
184208 end
185209
186210 # class InstallOptions
187- class InstallOptions
188- attr_accessor :platform , :force , :skip_client , :drivers , :driver_path , :debug
211+ class InstallOptions < T ::Struct
212+ include T ::Sig
213+
214+ prop :platform , T . nilable ( String )
215+ prop :force , T ::Boolean , default : false
216+ prop :skip_client , T ::Boolean , default : false
217+ prop :drivers , T ::Array [ String ] , default : [ ]
218+ prop :driver_path , T . nilable ( String )
219+ prop :debug , T ::Boolean , default : false
189220
190221 def create_parser
191222 OptionParser . new do |parser |
@@ -199,13 +230,7 @@ def create_parser
199230 end
200231 end
201232
202- # rubocop:disable Metrics/MethodLength
203233 def define_options ( parser )
204- @force = false
205- @skip_client = false
206- @drivers = [ ]
207- @debug = false
208-
209234 parser . on ( '--debug' , TrueClass , 'Enable debug mode' ,
210235 &method ( :debug= ) )
211236
@@ -229,13 +254,18 @@ def define_options(parser)
229254 'Path to the location of the driver wanted to be installed' ,
230255 &method ( :driver_path= ) )
231256 end
232- # rubocop:enable Metrics/MethodLength
233257 end
234258
235259 def parse ( args )
236260 left = @parser . order ( args )
237261 @mode = left . shift
238262 @sub_parser [ @mode ] &.order! ( left ) unless @mode . nil?
263+
264+ restore_session if @test . latest_session || @test . session
265+ end
266+
267+ def restore_session
268+ AutoHCK ::Session . load ( self )
239269 end
240270 end
241271end
0 commit comments