@@ -136,10 +136,12 @@ def run(args)
136136 case command
137137 when :version
138138 stdout . puts opts . ver
139+ 0
139140 when *COMMANDS
140141 __send__ :"run_#{ command } " , args , options
141142 else
142143 stdout . puts opts . help
144+ 0
143145 end
144146 end
145147
@@ -191,6 +193,8 @@ def run_ast(args, options)
191193
192194 stdout . print JSON . generate ( decls )
193195 stdout . flush
196+
197+ 0
194198 end
195199
196200 def run_list ( args , options )
@@ -254,6 +258,8 @@ def run_list(args, options)
254258 stdout . puts "#{ name } (interface)"
255259 end
256260 end
261+
262+ 0
257263 end
258264
259265 def run_ancestors ( args , options )
@@ -279,7 +285,7 @@ def run_ancestors(args, options)
279285
280286 unless args . size == 1
281287 stdout . puts "Expected one argument."
282- return
288+ return 1
283289 end
284290
285291 loader = options . loader ( )
@@ -317,6 +323,8 @@ def run_ancestors(args, options)
317323 else
318324 stdout . puts "Cannot find class: #{ type_name } "
319325 end
326+
327+ 0
320328 end
321329
322330 def run_methods ( args , options )
@@ -344,7 +352,7 @@ def run_methods(args, options)
344352
345353 unless args . size == 1
346354 stdout . puts "Expected one argument."
347- return
355+ return 1
348356 end
349357
350358 loader = options . loader ( )
@@ -373,6 +381,8 @@ def run_methods(args, options)
373381 else
374382 stdout . puts "Cannot find class: #{ type_name } "
375383 end
384+
385+ 0
376386 end
377387
378388 def run_method ( args , options )
@@ -398,7 +408,7 @@ def run_method(args, options)
398408
399409 unless args . size == 2
400410 stdout . puts "Expected two arguments, but given #{ args . size } ."
401- return
411+ return 1
402412 end
403413
404414 loader = options . loader ( )
@@ -410,7 +420,7 @@ def run_method(args, options)
410420
411421 unless env . module_name? ( type_name )
412422 stdout . puts "Cannot find class: #{ type_name } "
413- return
423+ return 1
414424 end
415425
416426 definition = case kind
@@ -426,7 +436,7 @@ def run_method(args, options)
426436
427437 unless method
428438 stdout . puts "Cannot find method: #{ method_name } "
429- return
439+ return 1
430440 end
431441
432442 stdout . puts "#{ type_name } #{ kind == :instance ? "#" : "." } #{ method_name } "
@@ -440,6 +450,8 @@ def run_method(args, options)
440450 stdout . puts format ( " %s %-#{ length_max } s at %s" , separator , type , type . location )
441451 separator = "|"
442452 end
453+
454+ 0
443455 end
444456
445457 def run_validate ( args , options )
@@ -469,7 +481,7 @@ def run_constant(args, options)
469481
470482 unless args . size == 1
471483 stdout . puts "Expected one argument."
472- return
484+ return 1
473485 end
474486
475487 loader = options . loader ( )
@@ -502,6 +514,8 @@ def run_constant(args, options)
502514 else
503515 stdout . puts " => [no constant]"
504516 end
517+
518+ 0
505519 end
506520
507521 def run_paths ( args , options )
@@ -544,6 +558,8 @@ def run_paths(args, options)
544558 stdout . puts "#{ dir } (#{ kind_of [ dir ] } , library, name=#{ source . name } )"
545559 end
546560 end
561+
562+ 0
547563 end
548564
549565 def run_prototype ( args , options )
@@ -647,6 +663,8 @@ def autoload(name, path)
647663
648664 writer = Writer . new ( out : stdout )
649665 writer . write decls
666+
667+ 0
650668 else
651669 stdout . puts <<EOU
652670Usage: rbs prototype [generator...] [args...]
@@ -660,7 +678,7 @@ def autoload(name, path)
660678 $ rbs prototype rbi foo.rbi
661679 $ rbs prototype runtime String
662680EOU
663- exit 1
681+ 1
664682 end
665683 end
666684
@@ -712,12 +730,12 @@ def run_prototype_file(format, args)
712730
713731 unless has_parser?
714732 stdout . puts "Not supported on this interpreter (#{ RUBY_ENGINE } )."
715- exit 1
733+ return 1
716734 end
717735
718736 if args . empty?
719737 stdout . puts opts
720- return nil
738+ return 1
721739 end
722740
723741 new_parser = -> do
@@ -827,6 +845,8 @@ def run_prototype_file(format, args)
827845 writer = Writer . new ( out : stdout )
828846 writer . write parser . decls
829847 end
848+
849+ 0
830850 end
831851
832852 def run_vendor ( args , options )
@@ -880,6 +900,8 @@ def run_vendor(args, options)
880900
881901 stdout . puts " Copying RBS files..."
882902 vendorer . copy!
903+
904+ 0
883905 end
884906
885907 def run_parse ( args , options )
@@ -927,7 +949,11 @@ def run_parse(args, options)
927949 syntax_error = true
928950 end
929951
930- exit 1 if syntax_error
952+ if syntax_error
953+ 1
954+ else
955+ 0
956+ end
931957 end
932958
933959 def run_annotate ( args , options )
@@ -975,6 +1001,8 @@ def run_annotate(args, options)
9751001 annotator . annotate_file ( path , preserve : preserve )
9761002 end
9771003 end
1004+
1005+ 0
9781006 end
9791007
9801008 def test_opt options
@@ -1028,7 +1056,7 @@ def run_test(args, options)
10281056
10291057 if args . length . zero?
10301058 stdout . puts opts . help
1031- exit 1
1059+ return 1
10321060 end
10331061
10341062 # @type var env_hash: Hash[String, String?]
@@ -1044,11 +1072,12 @@ def run_test(args, options)
10441072
10451073 # @type var out: String
10461074 # @type var err: String
1075+ # @type var status: Process::Status
10471076 out , err , status = __skip__ = Open3 . capture3 ( env_hash , *args )
10481077 stdout . print ( out )
10491078 stderr . print ( err )
10501079
1051- status
1080+ status . to_i
10521081 end
10531082
10541083 def run_collection ( args , options )
@@ -1073,7 +1102,7 @@ def run_collection(args, options)
10731102 when 'init'
10741103 if config_path . exist?
10751104 puts "#{ config_path } already exists"
1076- exit 1
1105+ return 1
10771106 end
10781107
10791108 config_path . write ( <<~'YAML' )
@@ -1101,15 +1130,17 @@ def run_collection(args, options)
11011130 when 'clean'
11021131 unless lock_path . exist?
11031132 puts "#{ lock_path } should exist to clean"
1104- exit 1
1133+ return 1
11051134 end
11061135 Collection ::Cleaner . new ( lockfile_path : lock_path )
11071136 when 'help' , 'hel' , 'he' , 'h'
11081137 puts opts . help
11091138 else
11101139 puts opts . help
1111- exit 1
1140+ return 1
11121141 end
1142+
1143+ 0
11131144 end
11141145
11151146 def collection_options ( args )
@@ -1171,7 +1202,7 @@ def run_subtract(args, _)
11711202 *minuend_paths , subtrahend_path = args
11721203 unless subtrahend_path
11731204 stdout . puts opts . help
1174- exit 1
1205+ return 1
11751206 end
11761207 subtrahend_paths << subtrahend_path
11771208 else
@@ -1180,7 +1211,7 @@ def run_subtract(args, _)
11801211
11811212 if minuend_paths . empty?
11821213 stdout . puts opts . help
1183- exit 1
1214+ return 1
11841215 end
11851216
11861217 subtrahend = Environment . new . tap do |env |
@@ -1213,10 +1244,12 @@ def run_subtract(args, _)
12131244 end
12141245 end
12151246 end
1247+
1248+ 0
12161249 end
12171250
12181251 def run_diff ( argv , library_options )
1219- Diff . new ( argv : argv , library_options : library_options , stdout : stdout , stderr : stderr ) . run
1252+ Diff . new ( stdout : stdout , stderr : stderr ) . run ( argv : argv , library_options : library_options )
12201253 end
12211254 end
12221255end
0 commit comments