From 6b036d66529be92af583f8559b5eb748105c5ff6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 Jan 2013 10:45:19 +0000 Subject: [PATCH] mogfiledebug: do not require --domain for --fid Specifying a domain (even a valid, non-existent one) when one is not needed hurts usability and confuses users. Set a dummy domain for MogileFS::Client if a domain is unspecified and --fid is used. --- mogfiledebug | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mogfiledebug b/mogfiledebug index 2ca1238..658c1b1 100755 --- a/mogfiledebug +++ b/mogfiledebug @@ -71,13 +71,19 @@ use LWP::UserAgent; my $util = MogileFS::Utils->new; my $usage = qq{--trackers=host --domain=foo --key='/hello.jpg' If FID is known, but domain/key are not known: ---trackers=host --domain=anything --fid=123456}; +--trackers=host --fid=123456}; # FIXME: add "nofetch" mode that just prints paths? my $c = $util->getopts($usage, qw/key=s fid=i/); -my $mogc = $util->client; +my $arg; +if ($c->{fid}) { + $c->{domain} ||= 'mogfiledebug-unset'; + $arg = 'fid'; +} else { + $arg = 'key'; +} -my $arg = $c->{fid} ? 'fid' : 'key'; +my $mogc = $util->client; my $details = $mogc->file_debug($arg => $c->{$arg}); if ($mogc->errcode) { die "Error fetching fid info: " . $mogc->errstr;