Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created January 16, 2012 14:44
Show Gist options
  • Save leejarvis/1621183 to your computer and use it in GitHub Desktop.
Save leejarvis/1621183 to your computer and use it in GitHub Desktop.
# Slop version 3
commands = Slop::Commands.new do
banner "ruby foo.rb [options]\n"
on 'new' do
on '-F', '--force', 'Force creation'
on '--outdir=', 'Output directory'
end
on 'version' do
add_callback(:empty) { p 'lolya' }
end
global do
on 'v', 'verbose', 'enable verbose mode'
end
default do
on 'a', 'auth', 'Auth mode'
end
end
puts commands #=>
__END__
~/code/slop[v3]% ruby run.rb
ruby foo.rb [options]
new
-F, --force Force creation
--outdir Output directory
global
-v, --verbose enable verbose mode
Other options
-a, --auth Auth mode
@epinault
Copy link

Looks pretty good. Liking it :)

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