1/* 2 * Copyright (c) 2009-2013 Zmanda, Inc. All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 * 14 * You should have received a copy of the GNU General Public License along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com 20 */ 21 22%perlcode %{ 23 24=head1 NAME 25 26Amanda::Cmdline - utilities for handling command lines 27 28=head1 SYNOPSIS 29 30 use Amanda::Cmdline; 31 32 my $spec = Amanda::Cmdline::dumpspec_t->new($host, $disk, $datestamp, $level, $write_timestamp); 33 print "host: $spec->{'host'}; disk: $spec->{'disk'}\n"; 34 35 my @specs = Amanda::Cmdline::parse_dumpspecs(["host", "disk", "date"], 36 $Amanda::Cmdline::CMDLINE_PARSE_DATESTAMP); 37 38=head1 Amanda::Cmdline::dumpspec_t Objects 39 40Note that this class was called C<Amanda::Cmdline::dumpspec_t> in older versions; 41that name will still work, but is deprecated. 42 43=head2 Keys 44 45Each key contains a match expression, in the form of a string, or undef. Note 46that the values of these keys are read-only. 47 48=over 49 50=item C<< $ds->{'host'} >> 51 52Hostname 53 54=item C<< $ds->{'disk'} >> 55 56Disk name 57 58=item C<< $ds->{'datestamp'} >> 59 60Dump timestamp. 61 62=item C<< $ds->{'level'} >> 63 64Dump level 65 66=item C<< $ds->{'write_timestamp'} >> 67 68Timestamp when the dump is written to storage media. 69 70=back 71 72=head2 Methods 73 74=over 75 76=item C<< $ds->format() >> 77 78Format the dumpspec as a string. 79 80=back 81 82=head1 Package Functions 83 84=over 85 86=item C<format_dumpspec_components($host, $disk, $datestamp, $level)> 87 88This function returns a string representing the formatted form of the 89given dumpspec. This formatting is the same as performed by 90C<< $ds->format() >>, but does not need a C<Dumpspec>. 91 92=item C<parse_dumpspecs([@cmdline], $flags)> 93 94This function parses C<@cmdline> into a list of C<Dumpspec> objects, 95according to C<$flags>, which is a logical combination of zero or more 96of 97 98 $CMDLINE_PARSE_DATESTAMP - recognize datestamps 99 $CMDLINE_PARSE_LEVEL - recognize levels 100 $CMDLINE_EMPTY_TO_WILDCARD - if @cmdline is empty, make a wildcard dumpspec 101 102These constants are available in export tag C<:constants>. The command-line 103format is 104 105 [host [disk [datestamp [level [host [..]]]]]] 106 107Note that there is no facility for specifying C<write_timestamp> on the command 108line. 109 110=item C<header_matches_dumpspecs($hdr, [@dumpspecs])> 111 112This function compares a header to a list of dumpspecs, returning true if the 113header matches at least one dumpspec. If C<@dumpspecs> is empty, the function 114returns false. 115 116=back 117 118=head1 SEE ALSO 119 120L<Amanda::Config> handles C<-o> options itself, through 121C<config_overrides>. 122 123=cut 124 125 126%} 127