.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Options 3pm" .TH Options 3pm "2021-02-09" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XMLTV::Options \- Command\-line parsing for XMLTV grabbers .SH "DESCRIPTION" .IX Header "DESCRIPTION" Utility library that implements command-line parsing and handles a lot of functionality that is common to all \s-1XMLTV\s0 grabbers. .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" All these functions are exported on demand. .SH "USAGE" .IX Header "USAGE" .IP "\fBParseOptions\fR" 4 .IX Item "ParseOptions" ParseOptions shall be called by a grabber to parse the command-line options supplied by the user. It takes a single hashref as a parameter. The entries in the hash configure the behaviour of ParseOptions. .Sp .Vb 10 \& my( $opt, $conf ) = ParseOptions( { \& grabber_name => \*(Aqtv_grab_test\*(Aq, \& version => \*(Aq1.2\*(Aq, \& description => \*(AqSweden (tv.swedb.se)\*(Aq, \& capabilities => [qw/baseline manualconfig apiconfig lineups/], \& stage_sub => \e&config_stage, \& listchannels_sub => \e&list_channels, \& list_lineups_sub => \e&list_lineups, \& get_lineup_sub => \e&get_lineup, \& } ); .Ve .Sp ParseOptions returns two hashrefs: .RS 4 .IP "\(bu" 4 A hashref with the values for all command-line options in the format returned by Getopt::Long (See \*(L"Storing options in a hash\*(R" in Getopt::Long). This includes both options that the grabber must handle as well as options that ParseOptions handles for the grabber. .IP "\(bu" 4 A hashref to the data loaded from the configuration file. See XMLTV::Configure for the format of \f(CW$conf\fR. .RE .RS 4 .Sp ParseOptions handles the following options automatically without returning: .IP "\-\-help" 4 .IX Item "--help" .PD 0 .IP "\-\-info (or \-\-man)" 4 .IX Item "--info (or --man)" .IP "\-\-capabilities" 4 .IX Item "--capabilities" .IP "\-\-version" 4 .IX Item "--version" .IP "\-\-description" 4 .IX Item "--description" .IP "\-\-preferredmethod" 4 .IX Item "--preferredmethod" .PD Handled automatically if the preferredmethod capability has been set and the preferredmethod option has been specified in the call to ParseOptions. .RE .RS 4 .Sp ParseOptions also takes care of the following options without returning, by calling the stage_sub, listchannels_sub, list_lineups_sub and get_lineup_sub callbacks supplied by the grabber: .IP "\-\-configure" 4 .IX Item "--configure" .PD 0 .IP "\-\-configure\-api" 4 .IX Item "--configure-api" .IP "\-\-stage" 4 .IX Item "--stage" .IP "\-\-list\-channels" 4 .IX Item "--list-channels" .IP "\-\-list\-lineups" 4 .IX Item "--list-lineups" .IP "\-\-get\-lineup" 4 .IX Item "--get-lineup" .RE .RS 4 .PD .Sp ParseOptions will thus only return to the grabber when the grabber shall actually grab data. .Sp If the \-\-output option is specified, \s-1STDOUT\s0 will be redirected to the specified file. .Sp The grabber must check the following options on its own: .IP "\-\-days" 4 .IX Item "--days" .PD 0 .IP "\-\-offset" 4 .IX Item "--offset" .IP "\-\-quiet" 4 .IX Item "--quiet" .IP "\-\-debug" 4 .IX Item "--debug" .RE .RS 4 .PD .Sp and any other options that are grabber specific. This can be done by reading \&\f(CW$opt\fR\->{days} etc. .RE .IP "\fBChanging the behaviour of ParseOptions\fR" 4 .IX Item "Changing the behaviour of ParseOptions" The behaviour of ParseOptions can be influenced by passing named arguments in the hashref. The following arguments are supported: .RS 4 .IP "grabber_name" 4 .IX Item "grabber_name" Required. The name of the grabber (e.g. tv_grab_se_swedb). This is used when printing the synopsis. .IP "description" 4 .IX Item "description" Required. The description for the grabber. This is returned in response to the \-\-description option and shall say which region the grabber returns data for. Examples: \*(L"Sweden\*(R", or \*(L"Sweden (tv.swedb.se)\*(R" if there are several grabbers for a region or country). .IP "version" 4 .IX Item "version" Required. The version number of the grabber to be displayed. Supported version string formats include \*(L"x\*(R", \*(L"x.y\*(R", and \*(L"x.y.z\*(R". .IP "capabilities" 4 .IX Item "capabilities" Required. The capabilities that the grabber shall support. Only capabilities that XMLTV::Options knows how to handle can be specified. Example: .Sp .Vb 1 \& capabilities => [qw/baseline manualconfig apiconfig/], .Ve .Sp Note that XMLTV::Options guarantees that the grabber supports the manualconfig and apiconfig capabilities. The capabilities share and cache can be specified if the grabber supports them. XMLTV::Options will then automatically accept the command-line parameters \-\-share and \-\-cache respectively. .IP "stage_sub" 4 .IX Item "stage_sub" Required. A coderef that takes a stage-name and a configuration hashref as a parameter and returns an xml-string that describes the configuration necessary for that stage. The xml-string shall follow the xmltv\-configuration.dtd. .IP "listchannels_sub" 4 .IX Item "listchannels_sub" Required. A coderef that takes a configuration hash as returned by XMLTV::Configure::LoadConfig as the first parameter and an option hash as returned by ParseOptions as the second parameter, and returns an xml-string containing a list of all the channels that the grabber can deliver data for using the supplied configuration. Note that the listsub shall not use any channel-configuration from the hashref. .IP "load_old_config_sub" 4 .IX Item "load_old_config_sub" Optional. Default undef. A coderef that takes a filename as a parameter and returns a configuration hash in the same format as returned by XMLTV::Configure::LoadConfig. load_old_config_sub is called if XMLTV::Configure::LoadConfig fails to parse the configuration file. This allows the grabber to load configuration files created with an older version of the grabber. .IP "list_lineups_sub" 4 .IX Item "list_lineups_sub" Optional. A coderef that takes an option hash as returned by ParseOptions as a parameter, and returns an xml-string containing a list of all the channel lineups for which the grabber can deliver data. The xml-string shall follow the xmltv\-lineups.xsd schema. .IP "get_lineup_sub" 4 .IX Item "get_lineup_sub" Optional. A coderef that returns an xml-string describing the configured lineup. The xml-string shall follow the xmltv\-lineups.xsd schema. .IP "preferredmethod" 4 .IX Item "preferredmethod" Optional. A value to return when the grabber is called with the \&\-\-preferredmethod parameter. Example: .Sp .Vb 11 \& my( $opt, $conf ) = ParseOptions( { \& grabber_name => \*(Aqtv_grab_test\*(Aq, \& version => \*(Aq1.2\*(Aq, \& description => \*(AqSweden (tv.swedb.se)\*(Aq, \& capabilities => [qw/baseline manualconfig apiconfig preferredmethod/], \& stage_sub => \e&config_stage, \& listchannels_sub => \e&list_channels, \& preferredmethod => \*(Aqallatonce\*(Aq, \& list_lineups_sub => \e&list_lineups, \& get_lineup_sub => \e&get_lineup, \& } ); .Ve .IP "defaults" 4 .IX Item "defaults" Optional. Default {}. A hashref that contains default values for the command-line options. It shall be in the same format as returned by Getopt::Long (See \*(L"Storing options in a hash\*(R" in Getopt::Long). .IP "extra_options" 4 .IX Item "extra_options" Optional. Default []. An arrayref containing option definitions in the format accepted by Getopt::Long. This can be used to support grabber-specific options. The use of grabber-specific options is discouraged. .RE .RS 4 .RE .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2005,2006 Mattias Holmlund. .PP This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \&\s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, \s-1MA\s0 02110\-1301, \s-1USA.\s0