From f37f0a917c4d82943e28dfedf85e95a79c113c77 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 19 May 2008 17:59:56 +0000 Subject: [PATCH] -Satisfy request 1965017, gettab and nodels now have -H support and default to no names if a single value is requested git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1443 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client-2.0/pods/man1/gettab.1.pod | 8 ++++++-- xCAT-client-2.0/pods/man1/nodels.1.pod | 8 ++++++-- xCAT-server-2.0/lib/xcat/plugins/tabutils.pm | 20 ++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/xCAT-client-2.0/pods/man1/gettab.1.pod b/xCAT-client-2.0/pods/man1/gettab.1.pod index 7a63404e1..28fd08312 100644 --- a/xCAT-client-2.0/pods/man1/gettab.1.pod +++ b/xCAT-client-2.0/pods/man1/gettab.1.pod @@ -4,7 +4,7 @@ B - search through tables using keys and return attributes. =head1 SYNOPSIS -B I +B [B<-H> | B<--with-fieldname>] I B [B<-?> | B<-h> | B<--help>] @@ -17,6 +17,10 @@ row, the specified attributes are displayed. =over 10 +=item B<-H|--with-fieldname> + +Always display table.column description next to result + =item B<-?|-h|--help> Display usage message. @@ -67,4 +71,4 @@ The output would be similar to: =head1 SEE ALSO -nodels(1), chtab(1), tabdump(1) \ No newline at end of file +nodels(1), chtab(1), tabdump(1) diff --git a/xCAT-client-2.0/pods/man1/nodels.1.pod b/xCAT-client-2.0/pods/man1/nodels.1.pod index bceaddc90..6ee927ae6 100644 --- a/xCAT-client-2.0/pods/man1/nodels.1.pod +++ b/xCAT-client-2.0/pods/man1/nodels.1.pod @@ -5,9 +5,9 @@ B - lists the nodes in the noderange. =head1 SYNOPSIS -B [I] [I | I] [I<...>] +B [I] [B<-H> | B<--with-fieldname>] [I | I] [I<...>] -B [I] [I] +B [I] [B<-H> | B<--with-fieldname>] [I
] B {B<-v> | B<--version>} @@ -56,6 +56,10 @@ will not do this, instead they will just display the single regular expression r Command Version. +=item B<-H|--with-fieldname> + +Force display table name and column name context for each result + =item B<-?|-h|--help> Display usage message. diff --git a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm index 476b9c8d2..92fe3e45c 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm @@ -129,11 +129,12 @@ sub gettab my $req = shift; my $callback = shift; my $HELP; + my $NOTERSE; sub gettab_usage { my $exitcode = shift @_; my %rsp; - push @{$rsp{data}}, "Usage: gettab key=value,... table.attribute ..."; + push @{$rsp{data}}, "Usage: gettab [-H|--with-fieldname] key=value,... table.attribute ..."; push @{$rsp{data}}, " gettab [-?|-h|--help]"; if ($exitcode) { $rsp{errorcode} = $exitcode; } $callback->(\%rsp); @@ -141,7 +142,7 @@ sub gettab # Process arguments @ARGV = @{$req->{arg}}; - if (!GetOptions('h|?|help' => \$HELP)) { gettab_usage(1); return; } + if (!GetOptions('h|?|help' => \$HELP,'H|with-fieldname' => \$NOTERSE)) { gettab_usage(1); return; } if ($HELP) { gettab_usage(0); return; } if (scalar(@ARGV)<2) { gettab_usage(1); return; } @@ -163,6 +164,9 @@ sub gettab # Group the columns asked for by table (so we can do 1 query per table) my %tabhash; my $terse = 2; + if ($NOTERSE) { + $terse = 0; + } foreach my $tabvalue (@ARGV) { $terse--; @@ -186,7 +190,7 @@ sub gettab (my $ent) = $tab->getAttribs(\%keyhash, keys %{$tabhash{$tabn}}); foreach my $coln (keys %{$tabhash{$tabn}}) { - if ($terse) { + if ($terse > 0) { $callback->({data => ["" . $ent->{$coln}]}); } else { $callback->({data => ["$tabn.$coln: " . $ent->{$coln}]}); @@ -739,7 +743,7 @@ sub nodels my $exitcode = shift @_; my %rsp; push @{$rsp{data}}, "Usage:"; - push @{$rsp{data}}, " nodels [noderange] [table.attribute | shortname] [...]"; + push @{$rsp{data}}, " nodels [noderange] [-H|--with-fieldname] [table.attribute | shortname] [...]"; push @{$rsp{data}}, " nodels {-v|--version}"; push @{$rsp{data}}, " nodels [-?|-h|--help]"; ##### xcat 1.2 nodels usage: @@ -758,7 +762,8 @@ sub nodels } @ARGV = @{$args}; - if (!GetOptions('h|?|help' => \$HELP, 'v|version' => \$VERSION,) ) { nodels_usage(1); return; } + my $NOTERSE; + if (!GetOptions('h|?|help' => \$HELP, 'H|with-fieldname' => \$NOTERSE, 'v|version' => \$VERSION,) ) { nodels_usage(1); return; } # Help if ($HELP) { nodels_usage(0); return; } @@ -781,6 +786,9 @@ sub nodels # } my $argc = @ARGV; my $terse = 2; + if ($NOTERSE) { + $terse = 0; + } if (@$nodes > 0 or $noderange) { #Make sure that there are zero nodes *and* that a noderange wasn't requested @@ -849,7 +857,7 @@ sub nodels foreach (keys %$rec) { my %datseg; - unless ($terse) { + unless ($terse > 0) { $datseg{data}->[0]->{desc} = [$labels{$_}]; } $datseg{data}->[0]->{contents} = [$rec->{$_}];