source: ProjectBuilder/devel/pb-modules/bin/pbgetparam@ 2175

Last change on this file since 2175 was 2175, checked in by Bruno Cornec, 7 years ago

Adds man, help and versions options to pbdistrocheck and pbgetparam

File size: 3.1 KB
RevLine 
[1690]1#!/usr/bin/perl -w
2#
3# Project Builder Distribution Parameter extractor
4#
5# $Id$
6#
[2032]7# Copyright B. Cornec 2007-2016
[1690]8# Provided under the GPL v2
9
10use strict 'vars';
11use Getopt::Long qw(:config auto_abbrev no_ignore_case);
12use Data::Dumper;
13use lib qw (lib);
14#use lib '/usr/share/perl5'; # mandatory for opensuse
[2175]15use ProjectBuilder::Version;
[1690]16use ProjectBuilder::Base;
17use ProjectBuilder::Env;
18use ProjectBuilder::Distribution;
19use ProjectBuilder::Conf;
20
21=pod
22
23=head1 NAME
24
25pb, aka project-builder.org - builds packages for your projects
26
27=head1 DESCRIPTION
28
29pb helps you build various packages directly from your project sources.
30pbdistrogetparam is a command from the pb project providing the value of the parameter for the running distribution based on the most precise tuple
31It is a CLI version of the pb_distro_get_param function
32
33=head1 SYNOPSIS
34
[1694]35pbdistrogetparam [-h][-v][-p project][-d distro-ver-arch] [param|-a]
[1690]36
37=head1 OPTIONS
38
39=over 4
40
41=item B<-h|--help>
42
43Prints this help
44
45=item B<-v|--verbose>
46
47Print a brief help message and exits.
48
49=item B<-d|--distribution>
50
51The tuple for which to print the parameter value considered (by default current distribution)
52
53=item B<-p|--project project_name>
54
55Name of the project you're working on (or use the env variable PBPROJ)
56
[1694]57=item B<-a|--all>
58
59Process all configuration parameters
60
[1690]61=back
62
63=head1 ARGUMENTS
64
65Arguments is mandatory and corresponds to the parameter whose value is requested for the related distribution tuple.
66
67=head1 WEB SITES
68
69The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
70
71=head1 USER MAILING LIST
72
73Cf: L<http://www.mondorescue.org/sympa/info/pb-announce> for announces and L<http://www.mondorescue.org/sympa/info/pb-devel> for the development of the pb project.
74
75=head1 CONFIGURATION FILES
76
77Uses the main /etc/pb/pb.conf (or /usr/local/etc/pb/pb.conf if installed from files) configuration file to give its answers.
78
79=head1 AUTHORS
80
81The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
82
83=head1 COPYRIGHT
84
85Project-Builder.org is distributed under the GPL v2.0 license
86described in the file C<COPYING> included with the distribution.
87
88=cut
89
90my %opts; # CLI Options
91
[2175]92my ($projectver,$projectrev) = pb_version_init();
93my $appname = "pbgetparam";
94
95# Initialize the syntax string
96
97pb_syntax_init("$appname Version $projectver-$projectrev\n");
98
[1690]99GetOptions(
100 "verbose|v+" => \$opts{'v'},
[2175]101 "version" => \$opts{'version'},
102 "man" => \$opts{'man'},
[1690]103 "help|h" => \$opts{'h'},
[1694]104 "all|a" => \$opts{'a'},
[1690]105 "project|p=s" => \$opts{'p'},
[1694]106 "distribution|d=s" => \$opts{'d'},
[1690]107);
[1694]108if (defined $opts{'h'}) {
[2175]109 pb_syntax(0,1);
[1694]110}
[2175]111if (defined $opts{'version'}) {
112 pb_syntax(0,0);
113}
[1694]114if (defined $opts{'man'}) {
115 pb_syntax(0,2);
116}
[1690]117if (defined $opts{'v'}) {
118 $pbdebug = $opts{'v'};
119}
120pb_log_init($pbdebug, \*STDOUT);
121
122my $dist = $opts{'d'};
[2153]123my $pbos = pb_distro_get_context($dist);
[2151]124pb_env_init($opts{'p'},0,"getconf",0);
[1694]125
126my @tab = @ARGV;
127@tab = pb_conf_get_all() if (defined $opts{'a'});
128
[2153]129pb_distro_conf_print($pbos,@tab);
Note: See TracBrowser for help on using the repository browser.