1 | #!/usr/bin/perl |
---|
2 | # ------------------------------------------------------------------------------ |
---|
3 | # (C) Crown copyright Met Office. All rights reserved. |
---|
4 | # For further details please refer to the file COPYRIGHT.txt |
---|
5 | # which you should have received as part of this distribution. |
---|
6 | # ------------------------------------------------------------------------------ |
---|
7 | |
---|
8 | use strict; |
---|
9 | use warnings; |
---|
10 | |
---|
11 | use FindBin; |
---|
12 | use lib "$FindBin::Bin/../lib"; |
---|
13 | use FCM::Admin::System qw{add_trac_environment}; |
---|
14 | use FCM::Admin::Util qw{option2config}; |
---|
15 | use Getopt::Long qw{GetOptions}; |
---|
16 | use Pod::Usage qw{pod2usage}; |
---|
17 | |
---|
18 | main(); |
---|
19 | |
---|
20 | sub main { |
---|
21 | my %option; |
---|
22 | my $result = GetOptions( |
---|
23 | \%option, |
---|
24 | q{admin-user|u=s@}, |
---|
25 | q{authorised|a}, |
---|
26 | q{help|usage|h}, |
---|
27 | q{svn-live-dir=s}, |
---|
28 | q{svn-project-suffix=s}, |
---|
29 | q{trac-live-dir=s}, |
---|
30 | ); |
---|
31 | if (!$result) { |
---|
32 | pod2usage(1); |
---|
33 | } |
---|
34 | if (exists($option{help})) { |
---|
35 | pod2usage(q{-verbose} => 1); |
---|
36 | } |
---|
37 | if (exists($option{'admin-user'})) { |
---|
38 | $option{'admin-user'} = [ |
---|
39 | split(q{,}, join(q{,}, @{$option{'admin-user'}})), |
---|
40 | ]; |
---|
41 | } |
---|
42 | option2config(\%option); |
---|
43 | if (@ARGV != 1) { |
---|
44 | my $message = sprintf( |
---|
45 | qq{Expected exactly 1 argument, %d given.}, scalar(@ARGV), |
---|
46 | ); |
---|
47 | pod2usage({q{-exitval} => 1, q{-message} => $message}); |
---|
48 | } |
---|
49 | my ($project_name) = @ARGV; |
---|
50 | add_trac_environment( |
---|
51 | $project_name, |
---|
52 | (exists($option{'admin-user'}) ? $option{'admin-user'} : []), |
---|
53 | exists($option{'authorised'}), |
---|
54 | ); |
---|
55 | } |
---|
56 | |
---|
57 | __END__ |
---|
58 | =head1 NAME |
---|
59 | |
---|
60 | fcm-add-trac-env |
---|
61 | |
---|
62 | =head1 SYNOPSIS |
---|
63 | |
---|
64 | fcm-add-trac-env [OPTIONS] PROJECT |
---|
65 | |
---|
66 | =head1 OPTIONS |
---|
67 | |
---|
68 | =over 4 |
---|
69 | |
---|
70 | =item --admin-user=LIST, -uLIST |
---|
71 | |
---|
72 | Specifies one or more admin users, in a comma separated list. |
---|
73 | |
---|
74 | =item --authorised, -a |
---|
75 | |
---|
76 | Adds an "authorised" permission. Only those users granted this permission |
---|
77 | will have "_CREATE" and "_MODIFY" access. The default is to grant all |
---|
78 | authenticated users "_CREATE" and "_MODIFY" access. |
---|
79 | |
---|
80 | =item --help, -h, --usage |
---|
81 | |
---|
82 | Prints help and exits. |
---|
83 | |
---|
84 | =item --svn-live-dir=DIR |
---|
85 | |
---|
86 | Specifies the root location of the live directory of Subversion repositories. |
---|
87 | See L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
88 | |
---|
89 | =item --svn-project-suffix=NAME |
---|
90 | |
---|
91 | Specifies the suffix added to the project name for Subversion repositories. The |
---|
92 | default is "_svn". |
---|
93 | |
---|
94 | =item --trac-live-dir=DIR |
---|
95 | |
---|
96 | Specifies the root location of the live directory of Trac environments. See |
---|
97 | L<FCM::Admin::Config|FCM::Admin::Config> for the current default. |
---|
98 | |
---|
99 | =back |
---|
100 | |
---|
101 | =head1 ARGUMENTS |
---|
102 | |
---|
103 | =over 4 |
---|
104 | |
---|
105 | =item PROJECT |
---|
106 | |
---|
107 | Specifies the name of the project to add. |
---|
108 | |
---|
109 | =back |
---|
110 | |
---|
111 | =head1 DESCRIPTION |
---|
112 | |
---|
113 | This program adds a new Trac environment to the live directory. |
---|
114 | |
---|
115 | =head1 COPYRIGHT |
---|
116 | |
---|
117 | E<169> Crown copyright Met Office. All rights reserved. |
---|
118 | |
---|
119 | =cut |
---|