Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created September 14, 2022 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr33n7007h/74eceec728c9e959d6f63e95eab6057c to your computer and use it in GitHub Desktop.
Save gr33n7007h/74eceec728c9e959d6f63e95eab6057c to your computer and use it in GitHub Desktop.
AstrallyForged
require 'optparse'
Arguments = Struct.new(:copies, :filename)
arguments = Arguments.new
options = ARGV.options do |opt|
opt.banner = "usage: #{opt.program_name} [options] <input file>"
opt.on '--copies=n', 'Number of copies', &:to_i
opt.on '-h', '--help', 'Displays this usage screen' do
puts opt
exit
end
end.freeze
options.permute! into: arguments
arguments.filename = ARGV.shift
p arguments
# ruby progname.rb --copies=5 statement.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment