bindgen icon indicating copy to clipboard operation
bindgen copied to clipboard

Use built in option parser for find_clang.cr

Open kalinon opened this issue 4 years ago • 3 comments

https://crystal-lang.org/api/0.34.0/OptionParser.html

require "option_parser"

upcase = false
destination = "World"

OptionParser.parse do |parser|
  parser.banner = "Usage: salute [arguments]"
  parser.on("-u", "--upcase", "Upcases the salute") { upcase = true }
  parser.on("-t NAME", "--to=NAME", "Specifies the name to salute") { |name| destination = name }
  parser.on("-h", "--help", "Show this help") do
    puts parser
    exit
  end
  parser.invalid_option do |flag|
    STDERR.puts "ERROR: #{flag} is not a valid option."
    STDERR.puts parser
    exit(1)
  end
end

destination = destination.upcase if upcase
puts "Hello #{destination}!"

kalinon avatar May 15 '20 18:05 kalinon

Related to #38

docelic avatar May 15 '20 19:05 docelic

(We could also use Stefan's toka, which is already used as part of bindgen)

docelic avatar May 16 '20 00:05 docelic

True, but i noticed find_clang was absent of any shard dependencies. Using the built in lib would continue this.

kalinon avatar May 16 '20 12:05 kalinon