diff --git a/exe/yard-to-rbs-inline b/exe/yard-to-rbs-inline index abec8f9..3144eda 100755 --- a/exe/yard-to-rbs-inline +++ b/exe/yard-to-rbs-inline @@ -1,8 +1,6 @@ #!/usr/bin/env ruby -if Dir.exist?(File.join(__dir__, "..", ".git")) - $LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) -end +$LOAD_PATH.unshift(File.expand_path("../lib", __dir__)) if Dir.exist?(File.join(__dir__, "..", ".git")) -require 'yard_to_rbs_inline' -YardToRbsInline::Cli.start(ARGV) +require "yard_to_rbs_inline" +exit(YardToRbsInline::Cli.start(ARGV)) diff --git a/lib/yard_to_rbs_inline/cli.rb b/lib/yard_to_rbs_inline/cli.rb index 52860a2..523efa9 100644 --- a/lib/yard_to_rbs_inline/cli.rb +++ b/lib/yard_to_rbs_inline/cli.rb @@ -1,6 +1,6 @@ # rbs_inline: enabled -require 'optparse' +require "optparse" module YardToRbsInline class Cli @@ -8,12 +8,24 @@ def self.start(argv) opt = OptionParser.new dry_run = false - opt.on('-n', '--dry-run', 'Dry run') { dry_run = true } + opt.banner = <<~STRING + Usage: yard-to-rbs-inline [options] + + 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 end end