Class: YardToRbsInline::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/yard_to_rbs_inline/cli.rb

Class Method Summary collapse

Class Method Details

.start(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/yard_to_rbs_inline/cli.rb', line 9

def self.start(argv)
  opt = OptionParser.new
  dry_run = false

  opt.banner = <<~STRING
    Usage: yard-to-rbs-inline [options] <files ...>

  STRING

  opt.on("-n", "--dry-run", "Dry run") { dry_run = true }
  opt.parse!(argv)

  if argv.empty?
    warn opt.help
    return 1
  end

  argv.each do |file|
    Converter.convert(file, dry_run: dry_run)
  end

  0
end