Permalink
Browse files

add "show".

  • Loading branch information...
1 parent 7c1afab commit 429c4567648aca0441283d6b7ed5949be65827d7 Robey Pointer committed Jun 30, 2010
Showing with 21 additions and 0 deletions.
  1. +14 −0 lib/gizzard/commands.rb
  2. +7 −0 lib/gizzmo.rb
View
@@ -145,6 +145,20 @@ def run
end
end
+ class ShowCommand < Command
+ def run
+ service.get_forwardings().sort_by do |f|
+ [ ((f.table_id.abs << 1) + (f.table_id < 0 ? 1 : 0)), f.base_id ]
+ end.each do |forwarding|
+ if @command_options.table_ids && !@command_options.table_ids.include?(forwarding.table_id) &&
+ !@command_options.table_ids.include?(-forwarding.table_id)
+ next
+ end
+ puts "%8d %015x %s" % [ forwarding.table_id, forwarding.base_id, forwarding.shard_id.to_unix ]
+ end
+ end
+ end
+
class LinksCommand < Command
def run
shard_ids = @argv
View
@@ -77,6 +77,13 @@ class HelpNeededError < RuntimeError; end
end,
'forward' => OptionParser.new do |opts|
opts.banner = "Usage: #{$0} forward TABLE_ID BASE_ID SHARD_ID"
+ end,
+ 'show' => OptionParser.new do |opts|
+ opts.banner = "Usage: #{$0} show [options]"
+
+ opts.on("-t", "--tables=IDS", "Show only the specified table ids (comma separated)") do |table_ids|
+ subcommand_options.table_ids = table_ids.split(",").map { |s| s.to_i }
+ end
end
}

0 comments on commit 429c456

Please sign in to comment.