Class: Switchboard::Commands::PubSub::Items
Class Method Summary
collapse
description, help, to_command, to_command_name
Class Method Details
.options(opts) ⇒ Object
7
8
9
10
|
# File 'lib/switchboard/commands/pubsub/items.rb', line 7
def self.options(opts)
super(opts)
opts.on("--item-count=count", Integer, "Specifies the number of items to retrieve.") { |v| OPTIONS["pubsub.items.count"] = v }
end
|
.run! ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/switchboard/commands/pubsub/items.rb', line 12
def self.run!
switchboard = Switchboard::Client.new do
defer :items_retrieved do
get_items_from(OPTIONS["pubsub.node"], OPTIONS["pubsub.items.count"])
end
def items_retrieved(items)
if items && items.any?
puts "Items:"
items.each do |id, item|
puts [id, item].compact * ": "
end
else
puts "No items available for node '#{OPTIONS["pubsub.node"]}'."
end
end
end
if defined?(OAuth) && OPTIONS["oauth"]
switchboard.plug!(OAuthPubSubJack)
else
switchboard.plug!(PubSubJack)
end
switchboard.run!
end
|