Papierkorb / bindgen

Binding and wrapper generator for C/C++ libraries
GNU General Public License v3.0
179 stars 18 forks source link

Use built in option parser for find_clang.cr #50

Open kalinon opened 4 years ago

kalinon commented 4 years ago

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}!"
docelic commented 4 years ago

Related to #38

docelic commented 4 years ago

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

kalinon commented 4 years ago

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