@@ -24,12 +24,13 @@ def process_global_options
2424 opts . banner = <<~USAGE
2525 Usage: steep [options]
2626
27- available commands: #{ CLI . available_commands . join ( ', ' ) }
27+ Available commands:
28+ #{ CLI . available_commands . join ( ', ' ) }
2829
2930 Options:
3031 USAGE
3132
32- opts . on ( "--version" ) do
33+ opts . on ( "--version" , "Print Steep version" ) do
3334 process_version
3435 exit 0
3536 end
@@ -60,6 +61,10 @@ def run
6061 __send__ ( :"process_#{ command } " )
6162 end
6263
64+ def handle_steepfile_option ( opts , command )
65+ opts . on ( "--steepfile=PATH" , "Specify path to Steepfile" ) { |path | command . steepfile = Pathname ( path ) }
66+ end
67+
6368 def handle_logging_options ( opts )
6469 opts . on ( "--log-level=LEVEL" , "Specify log level: debug, info, warn, error, fatal" ) do |level |
6570 Steep . logger . level = level
@@ -101,10 +106,16 @@ def setup_jobs_for_ci(jobs_option)
101106 def process_init
102107 Drivers ::Init . new ( stdout : stdout , stderr : stderr ) . tap do |command |
103108 OptionParser . new do |opts |
104- opts . banner = "Usage: steep init [options]"
109+ opts . banner = <<BANNER
110+ Usage: steep init [options]
111+
112+ Description:
113+ Generates a Steepfile at specified path.
105114
106- opts . on ( "--steepfile=PATH" ) { |path | command . steepfile = Pathname ( path ) }
107- opts . on ( "--force" ) { command . force_write = true }
115+ Options:
116+ BANNER
117+ handle_steepfile_option ( opts , command )
118+ opts . on ( "--force" , "Overwrite the Steepfile if it already exists" ) { command . force_write = true }
108119
109120 handle_logging_options opts
110121 end . parse! ( argv )
@@ -114,9 +125,19 @@ def process_init
114125 def process_check
115126 Drivers ::Check . new ( stdout : stdout , stderr : stderr ) . tap do |command |
116127 OptionParser . new do |opts |
117- opts . banner = "Usage: steep check [options] [sources]"
128+ opts . banner = <<BANNER
129+ Usage: steep check [options] [paths]
130+
131+ Description:
132+ Type check the program.
133+
134+ If paths are specified, it type checks and validates the files at the given path.
135+ Otherwise, it type checks and validates all files in the project or the groups if specified.
136+
137+ Options:
138+ BANNER
118139
119- opts . on ( "--steepfile=PATH" ) { | path | command . steepfile = Pathname ( path ) }
140+ handle_steepfile_option ( opts , command )
120141 opts . on ( "--with-expectations[=PATH]" , "Type check with expectations saved in PATH (or steep_expectations.yml)" ) do |path |
121142 command . with_expectations_path = Pathname ( path || "steep_expectations.yml" )
122143 end
@@ -179,9 +200,16 @@ def process_check
179200 def process_checkfile
180201 Drivers ::Checkfile . new ( stdout : stdout , stderr : stderr ) . tap do |command |
181202 OptionParser . new do |opts |
182- opts . banner = "Usage: steep checkfile [options] [files]"
203+ opts . banner = <<BANNER
204+ Usage: steep checkfile [options] [files]
183205
184- opts . on ( "--steepfile=PATH" ) { |path | command . steepfile = Pathname ( path ) }
206+ Description:
207+ Deprecated: Use `steep check` instead.
208+
209+ Options:
210+ BANNER
211+
212+ handle_steepfile_option ( opts , command )
185213 opts . on ( "--all-rbs" , "Type check all RBS files" ) { command . all_rbs = true }
186214 opts . on ( "--all-ruby" , "Type check all Ruby files" ) { command . all_ruby = true }
187215 opts . on ( "--stdin" , "Read files to type check from stdin" ) do
@@ -204,9 +232,16 @@ def process_checkfile
204232 def process_stats
205233 Drivers ::Stats . new ( stdout : stdout , stderr : stderr ) . tap do |command |
206234 OptionParser . new do |opts |
207- opts . banner = "Usage: steep stats [options] [sources]"
235+ opts . banner = <<BANNER
236+ Usage: steep stats [options] [sources]
237+
238+ Description:
239+ Displays statistics about the typing of method calls.
208240
209- opts . on ( "--steepfile=PATH" ) { |path | command . steepfile = Pathname ( path ) }
241+ Options:
242+ BANNER
243+
244+ handle_steepfile_option ( opts , command )
210245 opts . on ( "--format=FORMAT" , "Specify output format: csv, table" ) { |format | command . format = format }
211246 handle_jobs_option command . jobs_option , opts
212247 handle_logging_options opts
@@ -226,7 +261,14 @@ def process_validate
226261 def process_annotations
227262 Drivers ::Annotations . new ( stdout : stdout , stderr : stderr ) . tap do |command |
228263 OptionParser . new do |opts |
229- opts . banner = "Usage: steep annotations [options] [sources]"
264+ opts . banner = <<BANNER
265+ Usage: steep annotations [options] [sources]
266+
267+ Description:
268+ Prints the type annotations in the Ruby code.
269+
270+ Options:
271+ BANNER
230272 handle_logging_options opts
231273 end . parse! ( argv )
232274
@@ -237,8 +279,15 @@ def process_annotations
237279 def process_project
238280 Drivers ::PrintProject . new ( stdout : stdout , stderr : stderr ) . tap do |command |
239281 OptionParser . new do |opts |
240- opts . banner = "Usage: steep project [options]"
241- opts . on ( "--steepfile=PATH" ) { |path | command . steepfile = Pathname ( path ) }
282+ opts . banner = <<BANNER
283+ Usage: steep project [options]
284+
285+ Description:
286+ Prints the project configuration.
287+
288+ Options:
289+ BANNER
290+ handle_steepfile_option ( opts , command )
242291 opts . on ( "--[no-]print-files" , "Print files" ) { |v |
243292 command . print_files = v ? true : false
244293 }
@@ -250,7 +299,15 @@ def process_project
250299 def process_watch
251300 Drivers ::Watch . new ( stdout : stdout , stderr : stderr ) . tap do |command |
252301 OptionParser . new do |opts |
253- opts . banner = "Usage: steep watch [options] [dirs]"
302+ opts . banner = <<BANNER
303+ Usage: steep watch [options] [dirs]
304+
305+ Description:
306+ Monitors file changes and automatically type checks updated files.
307+ Using LSP is recommended for better performance and more features.
308+
309+ Options:
310+ BANNER
254311 opts . on ( "--severity-level=LEVEL" , /^error|warning|information|hint$/ , "Specify the minimum diagnostic severity to be recognized as an error (defaults: warning): error, warning, information, or hint" ) do |level |
255312 # @type var level: String
256313 command . severity_level = _ = level . to_sym
@@ -269,7 +326,15 @@ def process_watch
269326 def process_langserver
270327 Drivers ::Langserver . new ( stdout : stdout , stderr : stderr , stdin : stdin ) . tap do |command |
271328 OptionParser . new do |opts |
272- opts . on ( "--steepfile=PATH" ) { |path | command . steepfile = Pathname ( path ) }
329+ opts . banner = <<BANNER
330+ Usage: steep langserver [options]
331+
332+ Description:
333+ Starts language server, which is assumed to be invoked from language client.
334+
335+ Options:
336+ BANNER
337+ handle_steepfile_option ( opts , command )
273338 opts . on ( "--refork" ) { command . refork = true }
274339 handle_jobs_option command . jobs_option , opts
275340 handle_logging_options opts
@@ -301,8 +366,8 @@ def process_binstub
301366 opts . banner = <<BANNER
302367Usage: steep binstub [options]
303368
304- Generate a binstub to execute Steep with setting up Bundler and rbenv/rvm.
305- Use the executable for LSP integration setup .
369+ Description:
370+ Generate a binstub which set up ruby executables and bundlers .
306371
307372Options:
308373BANNER
@@ -373,6 +438,15 @@ def process_binstub
373438 end
374439
375440 def process_version
441+ OptionParser . new do |opts |
442+ opts . banner = <<BANNER
443+ Usage: steep version [options]
444+
445+ Description:
446+ Prints Steep version.
447+ BANNER
448+ end . parse! ( argv )
449+
376450 stdout . puts Steep ::VERSION
377451 0
378452 end
@@ -385,7 +459,7 @@ def process_worker
385459
386460 opts . on ( "--interaction" ) { command . worker_type = :interaction }
387461 opts . on ( "--typecheck" ) { command . worker_type = :typecheck }
388- opts . on ( "--steepfile=PATH" ) { | path | command . steepfile = Pathname ( path ) }
462+ handle_steepfile_option ( opts , command )
389463 opts . on ( "--name=NAME" ) { |name | command . worker_name = name }
390464 opts . on ( "--delay-shutdown" ) { command . delay_shutdown = true }
391465 opts . on ( "--max-index=COUNT" ) { |count | command . max_index = Integer ( count ) }
0 commit comments