[Bio] / FigKernelScripts / svr_get_set.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/svr_get_set.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : disz 1.1 use strict;
2 :    
3 :     use Getopt::Long;
4 :     use SeedEnv;
5 :     use PersistentSets;
6 :    
7 :     #
8 :     # This is a SAS Component
9 :     #
10 :    
11 :    
12 : disz 1.2 =head1 svr_get_set
13 : disz 1.1
14 :     List all the entries in a persistent set owned by owner
15 :    
16 :     The output is a list of set entries
17 :    
18 :     Owner name and set name(s) are required.
19 :    
20 :     Owner can be supplied with the -owner command line argument.
21 :    
22 :     Set name can be supplied with the -set_name argument only if the -owner argument is supplied.
23 :    
24 :     If -owner is supplied but not -set_name, set names are read from stdin, starting at column c.
25 :    
26 : disz 1.2 If neither set_name nor -owner is supplied, owner:set_name are read (starting at column -c) from stdin.
27 : disz 1.1
28 :    
29 : disz 1.2 Example: svr_get_set -owner owner_name -set_name set_name > set_contents.tbl
30 : disz 1.1
31 :     would produce a 1-column table of the contents of the set named set_name owned by owner.
32 :     ------
33 :    
34 :     =head2 Command-Line Options
35 :    
36 :     =over 4
37 :    
38 :     =item url
39 :    
40 :     The URL for the Sapling server, if it is to be different from the default.
41 :    
42 :     =item owner
43 :    
44 :     If supplied, owner name will be used for all subsequent operations
45 :    
46 :     =item set_name
47 :    
48 :     If supplied, the contents of this set will be returned
49 :    
50 :     =item -c Column
51 :    
52 :     This is used only if the column containing the input owner and/or set names is not the last.
53 :    
54 :     =back
55 :    
56 :     =head2 Output Format
57 :    
58 :     The standard output is a file where each line contains an owner name and a set name
59 :    
60 :     =cut
61 :    
62 :     my $usage = "usage: svr_get_sets [--owner=owner_name] [--set_name=set_name] >output\n";
63 :     my $owner = "";
64 :     my $set_name = "";
65 :     my $column;
66 :     my $url = '';
67 :     my $opted = GetOptions('c=i' => \$column, 'owner=s', \$owner, 'set_name=s', \$set_name, 'url=s', \$url);
68 :    
69 :     if (! $opted) { print STDERR $usage; exit }
70 :     if ($set_name) {
71 :     if (!$owner) {print "Missing Owner"; exit}
72 :     else {
73 :     print_set($owner, $set_name);
74 :     }
75 :     } else {
76 : disz 1.2
77 :    
78 :     my @sets = ScriptThing::GetList(\*STDIN, $column);
79 :    
80 :    
81 :     for my $set (@sets) {
82 :    
83 : disz 1.1 if ($owner) {
84 : disz 1.2 $set_name = $set;
85 : disz 1.1 } else {
86 : disz 1.2 ($owner, $set_name) = split(":", $set)
87 : disz 1.1 }
88 :     print_set($owner, $set_name);
89 :     }
90 :     }
91 :    
92 :    
93 :     sub print_set {
94 :     my ($owner, $set_name) = @_;
95 :     my $entries = PersistentSets::get_set($set_name, $owner);
96 :     for my $entry (@$entries) {
97 :     print $entry, "\n";
98 :     }
99 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3