Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built in option parser for find_clang.cr #50

Open
kalinon opened this issue May 15, 2020 · 3 comments
Open

Use built in option parser for find_clang.cr #50

kalinon opened this issue May 15, 2020 · 3 comments

Comments

@kalinon
Copy link
Contributor

kalinon commented May 15, 2020

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
Copy link
Collaborator

docelic commented May 15, 2020

Related to #38

@docelic
Copy link
Collaborator

docelic commented May 16, 2020

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

@kalinon
Copy link
Contributor Author

kalinon commented May 16, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants