/usr/bin/prima-cfgmaint is in libprima-perl 1.28-1.4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | #!/usr/bin/perl -w
#
# Copyright (c) 1997-2002 The Protein Laboratory, University of Copenhagen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Id: cfgmaint.pl,v 1.8 2005/10/13 17:22:52 dk Exp $
use Prima::VB::CfgMaint;
die <<ABOUT unless @ARGV;
format: cfgmaint [options] command object [parameters]
options:
-r use root config to write
-b use both user and root config to read
-x do not write backups
-o read-only mode
-p execute 'use Prima;' code
commands:
a - add p|m name
l - list w|p|m ( w - [page])
d - remove w|p|m name
r - rename w|p name new_name
m - move w|p name new_page or none to end
objects:
w - widgets
p - pages
m - modules
examples:
cfgmaint -r a m CPAN/Prima/VB/New/MyCtrls.pm
cfgmaint -b l w
ABOUT
my @cmd = ();
my $both = 0;
my $ro = 0;
$Prima::VB::CfgMaint::systemWide = 0;
$Prima::VB::CfgMaint::backup = 1;
for ( @ARGV) {
push( @cmd, $_), next unless /^-/;
$_ = lc $_;
s/^-//;
for ( split( '', $_)) {
if ( $_ eq 'b') {
$both = 1;
} elsif ( $_ eq 'r') {
$Prima::VB::CfgMaint::systemWide = 1;
} elsif ( $_ eq 'x') {
$Prima::VB::CfgMaint::backup = 0;
} elsif ( $_ eq 'o') {
$ro = 1;
} elsif ( $_ eq 'p') {
eval "use Prima;";
die "$@" if $@;
} else {
die "Unknown option: $_\n";
}
}
}
sub check
{
die "format: $cmd[0] [$_[0]]\n" if scalar @cmd < $_[1];
my %h = map { $_ => 1 } split( '', $_[0]);
return if $h{$cmd[1]};
die "Invalid sub-option: $cmd[1]. Use one of '$_[0]'\n";
}
sub assert
{
die "$_[1]\n" unless $_[0];
}
die "Insufficient number of parameters\n" if @cmd < 2;
$cmd[$_] = lc $cmd[$_] for 0..1;
if ( $cmd[0] eq 'a') {
check('pm', 3);
} elsif ( $cmd[0] eq 'l') {
check('wpm', 2);
} elsif( $cmd[0] eq 'd') {
check('wpm', 3);
} elsif( $cmd[0] eq 'r') {
check('wp', 4);
} elsif( $cmd[0] eq 'm') {
check('wp', 3);
die "Insufficient number of parameters\n" if @cmd < 4 && $cmd[1] eq 'w';
} else {
die "Unknown action: $cmd[0]\n";
}
my @r;
if ( $both) {
@r = Prima::VB::CfgMaint::read_cfg();
} else {
@r = Prima::VB::CfgMaint::open_cfg();
}
die "$r[1]\n" unless $r[0];
if ( $cmd[0] eq 'a') {
if ( $cmd[1] eq 'm') {
my %cs = %Prima::VB::CfgMaint::classes;
my %pg = map { $_ => 1} @Prima::VB::CfgMaint::pages;
assert( Prima::VB::CfgMaint::add_module( $cmd[2]));
for ( @Prima::VB::CfgMaint::pages) {
next if $pg{$_};
print "page '$_' added\n";
}
for ( keys %Prima::VB::CfgMaint::classes) {
next if $cs{$_};
print "widget '$_' added\n";
}
} elsif ( $cmd[1] eq 'p') {
my %pg = map { $_ => 1} @Prima::VB::CfgMaint::pages;
die "Page '$cmd[2]' already exists\n" if $pg{$cmd[2]};
push @Prima::VB::CfgMaint::pages, $cmd[2];
}
} elsif ( $cmd[0] eq 'l') {
if ( $cmd[1] eq 'w') {
my $ok = defined $cmd[2] ? 0 : 1;
for ( keys %Prima::VB::CfgMaint::classes) {
next if defined $cmd[2] && $Prima::VB::CfgMaint::classes{$_}-> {page} ne $cmd[2];
print "$_\n";
$ok = 1
}
die "Page '$cmd[2]' doesn't exist\n" unless $ok;
} elsif ( $cmd[1] eq 'p') {
print join( "\n", @Prima::VB::CfgMaint::pages);
} elsif ( $cmd[1] eq 'm') {
my %pk = ();
$pk{$Prima::VB::CfgMaint::classes{$_}-> {module}} = 1
for keys %Prima::VB::CfgMaint::classes;
for ( keys %pk) { print "$_\n"; }
}
exit;
} elsif( $cmd[0] eq 'd') {
if ( $cmd[1] eq 'w') {
die "Widget '$cmd[2]' doesn't exist\n" unless
$Prima::VB::CfgMaint::classes{$cmd[2]};
delete $Prima::VB::CfgMaint::classes{$cmd[2]};
} elsif ( $cmd[1] eq 'p') {
my @p;
for ( @Prima::VB::CfgMaint::pages) {
push ( @p, $_) unless $cmd[2] eq $_;
}
die "Page '$cmd[2]' doesn't exist\n"
if scalar @Prima::VB::CfgMaint::pages == scalar @p;
@Prima::VB::CfgMaint::pages = @p;
for ( keys %Prima::VB::CfgMaint::classes) {
next unless $Prima::VB::CfgMaint::classes{$_}-> {page} eq $cmd[2];
delete $Prima::VB::CfgMaint::classes{$_};
print "Widget '$_' deleted\n";
}
} elsif ( $cmd[1] eq 'm') {
my %dep;
my $ok = 0;
for ( keys %Prima::VB::CfgMaint::classes) {
unless ( $Prima::VB::CfgMaint::classes{$_}-> {module} eq $cmd[2]) {
$dep{$Prima::VB::CfgMaint::classes{$_}-> {page}} = 1;
next;
}
delete $Prima::VB::CfgMaint::classes{$_};
$ok = 1;
print "widget '$_' removed\n";
}
my @newpages;
for ( @Prima::VB::CfgMaint::pages) {
push ( @newpages, $_) , next if $dep{$_};
print "page '$_' removed\n";
}
@Prima::VB::CfgMaint::pages = @newpages;
die "Package '$cmd[2]' not found\n" unless $ok;
}
} elsif( $cmd[0] eq 'r') {
if ( $cmd[1] eq 'w') {
die "Widget '$cmd[2]' doesn't exist\n" unless
$Prima::VB::CfgMaint::classes{$cmd[2]};
die "Widget '$cmd[3]' already exist\n" if
$Prima::VB::CfgMaint::classes{$cmd[3]};
$Prima::VB::CfgMaint::classes{$cmd[3]} = $Prima::VB::CfgMaint::classes{$cmd[2]};
delete $Prima::VB::CfgMaint::classes{$cmd[2]};
} elsif ( $cmd[1] eq 'p') {
my %pg = map { $_ => 1} @Prima::VB::CfgMaint::pages;
die "Page '$cmd[2]' doesn't exist\n" unless $pg{$cmd[2]};
die "Page '$cmd[3]' already exist\n" if $pg{$cmd[3]};
for ( @Prima::VB::CfgMaint::pages) {
$_ = $cmd[3], last if $_ eq $cmd[2];
}
for ( keys %Prima::VB::CfgMaint::classes) {
$Prima::VB::CfgMaint::classes{$_}-> {page} = $cmd[3] if
$Prima::VB::CfgMaint::classes{$_}-> {page} eq $cmd[2];
}
}
} elsif( $cmd[0] eq 'm') {
if ( $cmd[1] eq 'w') {
my %pg = map { $_ => 1} @Prima::VB::CfgMaint::pages;
die "Page '$cmd[3]' doesn't exist\n" unless $pg{$cmd[3]};
die "Widget '$cmd[2]' doesn't exist\n" unless
$Prima::VB::CfgMaint::classes{$cmd[2]};
$Prima::VB::CfgMaint::classes{$cmd[2]}-> {page} = $cmd[3];
} elsif ( $cmd[1] eq 'p') {
my %pg = map { $_ => 1} @Prima::VB::CfgMaint::pages;
die "Page '$cmd[2]' doesn't exist\n" unless $pg{$cmd[2]};
die "Page '$cmd[3]' doesn't exist\n" if ! exists $pg{$cmd[3]} && defined $cmd[3];
my @p;
for ( @Prima::VB::CfgMaint::pages) {
push ( @p, $_) unless $cmd[2] eq $_;
}
@Prima::VB::CfgMaint::pages = @p;
@p = ();
if ( defined $cmd[3]) {
for ( @Prima::VB::CfgMaint::pages) {
push ( @p, $cmd[2]) if $_ eq $cmd[3];
push ( @p, $_);
}
@Prima::VB::CfgMaint::pages = @p;
} else {
push @Prima::VB::CfgMaint::pages, $cmd[2];
}
print join( "\n", @Prima::VB::CfgMaint::pages);
}
}
assert( Prima::VB::CfgMaint::write_cfg) unless $ro;
__DATA__
=pod
=head1 NAME
cfgmaint - configuration tool for Visual Builder
=head1 SYNTAX
cfgmaint [ -rbxop ] command object [ parameters ]
=head1 DESCRIPTION
Maintains widget palette configuration for the Visual Builder.
It can be stored in the system-wide and the local user config files.
C<cfgmaint> allows adding, renaming, moving, and deleting the
classes and pages in the Visual Builder widget palette.
=head1 USAGE
C<cfgmaint> is invoked with C<command> and C<object> arguments,
where C<command> defines the action to be taken, and C<object> -
the object to be handled.
=head2 Options
=over
=item -r
Write configuration to the system-wide config file
=item -b
Read configuration from both system-wide and user config files
=item -x
Do not write backups
=item -o
Read-only mode
=item -p
Execute C<use Prima;> code before start. This option
might be necessary when adding a module that relies on the toolkit
but does not invoke the code itself.
=back
=head2 Objects
=over
=item m
Selects a module. Valid for add, list, and remove commands.
=item p
Selects a page. Valid for all commands.
=item w
Selects a widget. Valid for list, remove, rename, and move commands.
=back
=head2 Commands
=over
=item a
Adds a new object to the configuration. Can be either a page or
a module.
=item d
Removes an object.
=item l
Prints object name. In case object is a widget, prints all
registered widgets. If the string is specified as an additional
parameter, it is treated as a page name and only widgets from
the page are printed.
=item r
Renames an object to a new name, which is passed as additional parameter.
Can be either a widget or a page.
=item m
If C<object> is a widget, relocates one or more widgets to a new page.
If C<object> is a page, moves the page before the page specified as an additional parameter,
or to the end if no additional page specified.
=back
=head1 EXAMPLE
Add a new module to the system-wide configuration:
cfgmaint -r a m CPAN/Prima/VB/New/MyCtrls.pm
List widgets, present in both config files:
cfgmaint -b l w
Rename a page:
cfgmaint r p General Basic
=head1 FILES
F<Prima/VB/Config.pm>, F<~/.prima/vbconfig>
=head1 AUTHOR
Dmitry Karasik, E<lt>dmitry@karasik.eu.orgE<gt>.
=head1 SEE ALSO
L<VB>, L<Prima::VB::CfgMaint>
=cut
|