Skip to content

Commit 5f24b6e

Browse files
authored
Merge pull request #22 from cloudamqp/add-z-option
2 parents 941b1eb + 968b65e commit 5f24b6e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/amqpcat.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class AMQPCat
1313
@client = AMQP::Client.new(u)
1414
end
1515

16+
def connect
17+
@client.connect
18+
end
19+
1620
def produce(exchange : String, routing_key : String, exchange_type : String, publish_confirm : Bool, props : AMQP::Client::Properties)
1721
STDIN.blocking = false
1822
loop do

src/cli.cr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ p = OptionParser.parse do |parser|
6161
parser.on("--content-encoding=ENC", "Content encoding header") { |v| props.content_encoding = v }
6262
parser.on("--priority=LEVEL", "Priority header") { |v| props.priority = v.to_u8? || abort "Priority must be between 0 and 255" }
6363
parser.on("--expiration=TIME", "Expiration header (ms before msg is dead lettered)") { |v| props.expiration = v }
64+
parser.on("-z", "Exit on connection") { mode = :connect }
6465
parser.on("-v", "--version", "Display version") { puts AMQPCat::VERSION; exit 0 }
6566
parser.on("-h", "--help", "Show this help message") { puts parser; exit 0 }
6667
parser.invalid_option do |flag|
@@ -70,6 +71,7 @@ p = OptionParser.parse do |parser|
7071
end
7172

7273
cat = AMQPCat.new(uri)
74+
7375
case mode
7476
when :producer
7577
unless exchange || queue
@@ -93,4 +95,7 @@ when :rpc
9395
abort p
9496
end
9597
cat.rpc(exchange, routing_key.not_nil!, exchange_type, format)
98+
when :connect
99+
cat.connect
100+
exit 0
96101
end

0 commit comments

Comments
 (0)