]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - tools/directive
Fix showing the start header when using --version.
[user/henk/code/inspircd.git] / tools / directive
1 #!/usr/bin/env perl
2 #
3 # InspIRCd -- Internet Relay Chat Daemon
4 #
5 #   Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
6 #
7 # This file is part of InspIRCd.  InspIRCd is free software: you can
8 # redistribute it and/or modify it under the terms of the GNU General Public
9 # License as published by the Free Software Foundation, version 2.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20
21 BEGIN {
22         require 5.10.0;
23         unless (-f 'configure') {
24                 print "Error: $0 must be run from the main source directory!\n";
25                 exit 1;
26         }
27 }
28
29 use feature ':5.10';
30 use strict;
31 use warnings FATAL => qw(all);
32
33 use File::Basename qw(dirname);
34 use FindBin        qw($RealDir);
35
36 use lib dirname $RealDir;
37 use make::console;
38 use make::directive;
39
40 if (scalar @ARGV < 2) {
41         print_format "<|GREEN Usage:|> $0 <<|UNDERLINE FILE|>> [<|UNDERLINE DIRECTIVES...|>]\n", *STDERR;
42         exit 1
43 }
44
45 my $file = shift;
46 print_error "<|GREEN $file|> does not exist and/or is not a file!" unless -f $file;
47
48 for my $directive (@ARGV) {
49         my $value = get_directive $file, $directive, '';
50         if (-t STDOUT) {
51                 print_format "<|GREEN $directive|>: $value\n";
52         } else {
53                 say $value;
54         }
55 }