9 =head1 NAME $RCSfile: cqinfo.pl,v $
13 This script takes some parameters and gets information from a Clearquest
22 Andrew DeFaria <Andrew@ClearSCM.com>
30 Mon Jul 30 12:05:45 PDT 2012
34 $Date: 2013/03/15 00:19:36 $
40 Usage: cqinfo.pl [-u|sage] [-v|erbose] [-d|ebug]
41 [-username <username>] [-password <password>]
42 [-database <dbname>] [-dbset <dbset>]
43 [-record <record>] [-key <key>]
44 [-fields <field1>,<field2>,...]
45 [-module] [-server <server>] [-port <port>]
48 -u|sage: Displays usage
50 -de|bug: Output debug messages
52 -r|ecord: Record to interrogate (Default: Defect)
53 -k|ey: Key to locate the record with (Note that if you supply
54 simply a number (e.g. 1234) then we will expand that with
55 leading zeroes to the length of 8 digits and prepend the
57 -f|ields: List of fields to display (Default: All fields)
59 -use|rname: Username to open database with (Default: from config file)
60 -p|assword: Password to open database with (Default: from config file)
61 -da|tabase: Database to open (Default: from config file)
62 -db|set: Database Set to use (Default: from config file)
63 -m|odule: Type of Clearquest module to use. Must be one of 'api',
64 'client', or 'rest'. The 'api' module can only be used if
65 Clearquest is installed locally. The 'client' module can
66 only be successful if a corresponding server is running. And
67 the 'rest' module can only be used if a CQ Web server has
68 been set up and configured (Default: rest)
69 -s|erver: For module = client or rest this is the name of the server
70 that will be providing the service
71 -p|ort: For module = client, this is the point on the server to talk
76 Options are keep in the cq.conf file in etc. They specify the default options
77 listed below. Or you can export the option name to the env(1) to override the
78 defaults in cq.conf. Finally you can programmatically set the options when you
79 call new by passing in a %parms hash. To specify the %parms hash key remove the
80 CQ_ portion and lc the rest.
82 =for html <blockquote>
88 The web host to contact with leading http://
92 Name of database to connect to (Default: from config file)
96 User name to connect as (Default: from config file)
100 Password for CQ_USERNAME
104 Database Set name (Default: from config file)
108 Clearquest::Server name to connect to (Default: from config file)
112 Clearquest::Server port to connect to (Default: from config file)
121 use lib "$FindBin::Bin/../lib";
131 usage => sub { Usage },
132 verbose => sub { set_verbose },
133 debug => sub { set_debug },
146 Usage "You must specify -key" unless $opts{key};
148 $opts{module} = lc $opts{module} if $opts{module};
151 my $record = delete $opts{record} || 'Defect';
152 my $key = delete $opts{key};
156 push @fields, split /\s*,\s*/ foreach (@{$opts{fields}});
159 # Translate any options to ones that the lib understands
160 $opts{CQ_USERNAME} = delete $opts{username};
161 $opts{CQ_PASSWORD} = delete $opts{password};
162 $opts{CQ_DATABASE} = delete $opts{database};
163 $opts{CQ_DBSET} = delete $opts{dbset};
164 $opts{CQ_SERVER} = delete $opts{server};
165 $opts{CQ_PORT} = delete $opts{port};
169 my $module = delete $opts{module};
171 $cq = Clearquest->new (%opts);
175 # Fix key if necessary
176 if ($key =~ /^(\d+)$/) {
177 $key = $cq->{database} . 0 x (8 - length $1) . $1;
180 my %record = $cq->get ($record, $key, @fields);
182 unless ($cq->error) {
183 foreach my $field (sort keys %record) {
184 if (ref $record{$field} eq 'ARRAY') {
185 display "$field (LIST):";
187 display "\t$_" foreach (@{$record{$field}});
189 display_nolf "$field: ";
191 if ($record{$field}) {
192 display $record{$field};
201 error "Unable to get $record with key $key\n" . $cq->errmsg, $cq->error;