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 . nilable ( T ::Boolean ) , default : false
28+ prop :config , T . nilable ( String )
29+ prop :client_world_net , T . nilable ( 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
@@ -81,11 +83,27 @@ def define_options(parser)
8183 end
8284
8385 # 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
86+ class TestOptions < T ::Struct
87+ include T ::Sig
88+
89+ prop :platform , T . nilable ( String )
90+ prop :drivers , T . nilable ( T ::Array [ String ] )
91+ prop :driver_path , T . nilable ( String )
92+ prop :commit , T . nilable ( String )
93+ prop :svvp , T . nilable ( T ::Boolean )
94+ prop :dump , T . nilable ( T ::Boolean )
95+ prop :gthb_context_prefix , T . nilable ( String )
96+ prop :gthb_context_suffix , T . nilable ( String )
97+ prop :playlist , T . nilable ( String )
98+ prop :select_test_names , T . nilable ( String )
99+ prop :reject_test_names , T . nilable ( String )
100+ prop :reject_report_sections , T . nilable ( T ::Array [ String ] ) , default : [ ]
101+ prop :boot_device , T . nilable ( String )
102+ prop :allow_test_duplication , T . nilable ( T ::Boolean )
103+ prop :manual , T . nilable ( T ::Boolean )
104+ prop :package_with_playlist , T . nilable ( T ::Boolean )
105+ prop :session , T . nilable ( String )
106+ prop :latest_session , T . nilable ( T ::Boolean )
89107
90108 def create_parser
91109 OptionParser . new do |parser |
@@ -179,13 +197,28 @@ def define_options(parser)
179197 parser . on ( '--package-with-playlist' , TrueClass ,
180198 'Load playlist into HLKX project package' ,
181199 &method ( :package_with_playlist= ) )
200+
201+ parser . on ( '--session <path>' , String ,
202+ 'Load session from workspace' ,
203+ &method ( :session= ) )
204+
205+ parser . on ( '--latest-session' , TrueClass ,
206+ 'Load previous session' ,
207+ &method ( :latest_session= ) )
182208 end
183209 # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
184210 end
185211
186212 # class InstallOptions
187- class InstallOptions
188- attr_accessor :platform , :force , :skip_client , :drivers , :driver_path , :debug
213+ class InstallOptions < T ::Struct
214+ include T ::Sig
215+
216+ prop :platform , T . nilable ( String )
217+ prop :force , T ::Boolean , default : false
218+ prop :skip_client , T ::Boolean , default : false
219+ prop :drivers , T ::Array [ String ] , default : [ ]
220+ prop :driver_path , T . nilable ( String )
221+ prop :debug , T ::Boolean , default : false
189222
190223 def create_parser
191224 OptionParser . new do |parser |
@@ -236,6 +269,12 @@ def parse(args)
236269 left = @parser . order ( args )
237270 @mode = left . shift
238271 @sub_parser [ @mode ] &.order! ( left ) unless @mode . nil?
272+
273+ restore_session if @test . latest_session || @test . session
274+ end
275+
276+ def restore_session
277+ AutoHCK ::Session . load ( self )
239278 end
240279 end
241280end
0 commit comments