Skip to content

Commit

Permalink
Add command line helps
Browse files Browse the repository at this point in the history
  • Loading branch information
tomoasleep committed May 16, 2024
1 parent 587e44d commit 15552d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 3 additions & 5 deletions exe/yard-to-rbs-inline
Original file line number Diff line number Diff line change
@@ -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))
16 changes: 14 additions & 2 deletions lib/yard_to_rbs_inline/cli.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# rbs_inline: enabled

require 'optparse'
require "optparse"

module YardToRbsInline
class Cli
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] <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
end
end

0 comments on commit 15552d1

Please sign in to comment.