Skip to content

Commit b02df4d

Browse files
authored
Merge pull request #136 from sue445/dist_dir_arg
Add --dist-dir to ruby_h_to_go
2 parents 56e1285 + cb664d5 commit b02df4d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

_tools/ruby_h_to_go/exe/ruby_h_to_go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@ require "fileutils"
1212
require_relative "../lib/ruby_h_to_go"
1313

1414
header_dir = nil
15+
dist_dir = nil
16+
17+
DEFAULT_RUBY_HEADER_DIR = RbConfig::CONFIG["rubyhdrdir"]
18+
DEFAULT_DIST_DIR = File.expand_path("../dist", __dir__)
1519

1620
opt = OptionParser.new
17-
opt.on("-H HEADER_DIR") { |v| header_dir = v }
21+
opt.on("-H", "--header-dir HEADER_DIR", "ruby header dir (default: #{DEFAULT_RUBY_HEADER_DIR})") { |v| header_dir = v }
22+
23+
opt.on("-D", "--dist-dir DIST_DIR", "dist dir for auto-generated Go code (default: #{DEFAULT_DIST_DIR})") do |v|
24+
dist_dir = v
25+
end
1826

1927
opt.parse!(ARGV)
2028

2129
# Use default header file and include paths
22-
header_dir ||= RbConfig::CONFIG["rubyhdrdir"]
30+
header_dir ||= DEFAULT_RUBY_HEADER_DIR
31+
32+
dist_dir ||= DEFAULT_DIST_DIR
2333

24-
RubyHToGo::Cli.new(header_dir:, dist_dir: File.join(__dir__, "..", "dist")).perform
34+
RubyHToGo::Cli.new(header_dir:, dist_dir:).perform

0 commit comments

Comments
 (0)