Skip to content

Instantly share code, notes, and snippets.

@brandonpittman
Created March 28, 2016 02:57
Show Gist options
  • Save brandonpittman/941d6b55aa4594e8cc9b to your computer and use it in GitHub Desktop.
Save brandonpittman/941d6b55aa4594e8cc9b to your computer and use it in GitHub Desktop.
Hello world in Crystal
require "option_parser"
capitalize = false
destination = "World"
OptionParser.parse! do |parser|
parser.banner = "Usage: salute [arguments]"
parser.on("-c", "--capitalize", "Capitalizes the sallute") { capitalize = true }
parser.on("-t NAME", "--to=NAME", "Specifies the name to salute") { |name| destination = name }
parser.on("-h", "--help", "Show this help") { puts parser }
end
destination = destination.capitalize if capitalize
puts "Hello #{destination}!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment