Skip to content

Instantly share code, notes, and snippets.

@wolfedale
Last active August 29, 2015 14:19
Show Gist options
  • Save wolfedale/19b6fbeb6e5ebfaba105 to your computer and use it in GitHub Desktop.
Save wolfedale/19b6fbeb6e5ebfaba105 to your computer and use it in GitHub Desktop.
require 'getoptlong'
opts = GetoptLong.new(
[ '--directory', '-d', GetoptLong::REQUIRED_ARGUMENT],
[ '--pattern', '-p', GetoptLong::REQUIRED_ARGUMENT],
[ '--help', '-h', GetoptLong::NO_ARGUMENT]
)
def showhelp
puts "HELP"
end
dirname = ""
pattern = ""
opts.each do |opt, arg|
case opt
when '--help'
showhelp
exit
when '--directory'
dirname = arg
when '--pattern'
pattern = arg
end
end
if dirname == "" || pattern == ""
showhelp
exit
end
puts dirname
puts pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment