This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'slop' | |
opts = Slop.parse do | |
banner "ruby app.rb {clean,compile,start} [OPTIONS]" | |
on :v, 'Display the version of App' do | |
puts 'Version 1.5!' | |
exit | |
end | |
on :V, :verbose, 'Enable verbose mode' | |
on_empty do | |
puts help | |
end | |
command :clean do | |
on :v, 'Enable verbose mode' | |
on :a, :all, 'Clean all?' | |
end | |
command :compile do | |
banner "ruby app.rb compile [OPTIONS]" | |
on :d, :dir, 'Out directory', true | |
on :i, :items, 'Range of items. ex: 1,10', true, :as => Range | |
on_empty do | |
puts help | |
end | |
end | |
end | |
if opts[:compile].items? # check if option is present | |
p opts[:compile][:items].to_a | |
end | |
# Try with the following for ARGV: | |
# ruby app.rb | |
# ruby app.rb -v | |
# ruby app.rb compile | |
# ruby app.rb compile -i 1,10 | |
# many more .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment