Skip to content

Instantly share code, notes, and snippets.

@hannesfostie
Created July 10, 2013 12:53
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 hannesfostie/3a1e2d0b80c9b547b06f to your computer and use it in GitHub Desktop.
Save hannesfostie/3a1e2d0b80c9b547b06f to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'slop'
require 'sock_admin'
options = Slop.parse do
banner %{Usage: sock_admin COMMAND [OPTIONS]
Control Sock from the command line.
}
on :v, :version, 'Display the version' do
puts "SockAdmin Version #{SockAdmin::VERSION}"
end
# this should be global so I don't have to repeat this block inside of each command. 'global do' no longer works?
on :help, 'Displays this help message' do
puts help
exit
end
# I'd like a summary here about what to expect when using the chef command, just the way you describe an option
command 'chef' do
on :help, 'Displays this help message' do
puts help
exit
end
command 'last' do
# the host or h option is required, and as such it might make less sense to require it as a flag but rather assume there'll be an argument here instead ?
on :h, :host=, "Displays last Chef run for the specified host"
on :e, :environment=, "Set the Sock environment"
# this is the same as the previous one, it doesn't allow 3 ways of specifying this. Hardly a big deal though
on :env=, "Set the Sock environment"
on :help, 'Displays this help message' do
puts help
exit
end
run do |options, args|
# does stuff
end
end
command 'run' do
on :h, :host=, "Runs Chef on the specified host"
on :e, :environment=, "Set the Sock environment"
on :env=, "Set the Sock environment"
on :help, 'Displays this help message' do
puts help
exit
end
run do |options, args|
# does stuff
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment