10 use CXGN
::Publish qw
/publish/;
13 my $message = shift || '';
14 $message = "Error: $message\n" if $message;
18 $FindBin::Script <options> rm FILE...
19 $FindBin::Script <options> rm -f FILE...
20 $FindBin::Script <options> cp SOURCE... DEST
21 $FindBin::Script <options> cp SOURCE... DIRECTORY
22 $FindBin::Script <options> touch FILE
24 Do deletes or copies, preserving a file-based version history of the
25 target file(s). Try it out, you'll see what I mean.
27 Makes its best effort to keep the operation atomic. For example, if
28 you're copying a bunch of files to a directory and the destination
29 runs out of disk space, all of the files that _were_ copied will be
30 removed, and the old ones put back in place, as if the operation
33 Note that operations are skipped if the new file is the same as the
38 rm 'remove' the target file. Die if it is not present.
39 rm -f 'remove' the target file. Ignore if not present.
40 cp 'copy' the source(s) to the destination
41 touch right now, simply ensures that the proper curr/ symlink is
42 present, making it if necessary.
44 Uses the CXGN::Publish module. If you need to do more than what's
45 provided by this script, chances are you can do it by using the
50 -x dry run. don't actually do anything, just print.
54 -d create target directories if necessary
56 -b bac repository mode. processes filename extensions a bit
57 differently to allow for sequence versions. Requires
58 CXGN::TomatoGenome::BACPublish to be installed
62 #get command-line switches
64 getopts
('vxdb',\
%opt) or usage
();
65 $CXGN::Publish
::print_ops
= 1 if $opt{v
};
66 $CXGN::Publish
::dry_run
= 1 if $opt{x
};
67 $CXGN::Publish
::make_dirs
= 1 if $opt{d
};
69 #parse the rest of the arguments
72 my @operands = @ARGV; #the
73 my $operation = shift @operands; #the operation we will perform
74 if($operation eq 'rm' && $operands[0] eq '-f') {
79 #assemble the list of publishing operations (see CXGN::Publish)
80 my @publish_operations = do {
82 if( $operation eq 'rm' || $operation eq 'rm -f' || $operation eq 'touch' ) {
83 map {[$operation,$_]} @operands
85 elsif($operation eq 'cp') {
86 my $destination = pop @operands;
87 @operands == 1 or -d
$destination or $opt{d
} or die "'$destination' is not a directory\n";
88 map {['cp',$_,$destination]} @operands;
91 usage
("unknown operation '$operation'");
96 #do the publish operation
98 eval 'require CXGN::TomatoGenome::BACPublish';
99 die "Cannot load CXGN::TomatoGenome::BACPublish, required for -b mode:\n$@" if $@
;
100 CXGN
::TomatoGenome
::BACPublish
::bac_publish
(@publish_operations);
103 publish
(@publish_operations);