Class: Serf::Handler::Cli
- Inherits:
-
Hash
- Object
- Hash
- Serf::Handler::Cli
- Defined in:
- lib/serf/handler/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize ⇒ Cli
Returns a new instance of Cli.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/serf/handler/cli.rb', line 6 def initialize OptionParser.new do |opts| opts. = "Usage: handler [options]\n\nWhen given CLI options, payload items that are normally passed to the handler via Serf can be specified manually." opts.separator '' opts.on('-t','--type [TYPE]',[:query, :event],'The type of request to trigger -- a query or an event. Defaults to an event.') do |type| self[:type] = type end opts.on('-n','--name [NAME]',String,'The name of the query or event to trigger.') do |name| self[:name] = name end opts.on('-p','--payload [PAYLOAD]',String,'The payload to deliver to the event handler that processes the request.') do |payload| self[:payload] = payload.to_s end end.parse! end |