[rt-commit] [svn] r516 - rt/branches/rt-3.1/bin
jesse at fsck.com
jesse at fsck.com
Tue Mar 9 17:09:39 EST 2004
Author: jesse
Date: Tue Mar 9 17:09:39 2004
New Revision: 516
Modified:
rt/branches/rt-3.1/bin/rt.in
Log:
#5088: CLI hacking from AMS to prepare for an interactive 'rt shell'
Modified: rt/branches/rt-3.1/bin/rt.in
==============================================================================
--- rt/branches/rt-3.1/bin/rt.in (original)
+++ rt/branches/rt-3.1/bin/rt.in Tue Mar 9 17:09:39 2004
@@ -86,18 +86,25 @@
grant => ["grant", "revoke"],
);
-# Once we find and call an appropriate handler, we're done.
-
-my (%actions, $action);
+my %actions;
foreach my $fn (keys %handlers) {
foreach my $alias (@{ $handlers{$fn} }) {
$actions{$alias} = \&{"$fn"};
}
}
-if (@ARGV && exists $actions{$ARGV[0]}) {
- $action = shift @ARGV;
+
+# Once we find and call an appropriate handler, we're done.
+
+sub handle {
+ my $action;
+
+ if (@ARGV && exists $actions{$ARGV[0]}) {
+ $action = shift @ARGV;
+ }
+ $actions{$action || "help"}->($action || ());
}
-$actions{$action || "help"}->($action || ());
+
+handle(@ARGV);
exit;
# Handler functions.
@@ -113,18 +120,21 @@
submit("$REST/logout") if defined $session->cookie;
}
+my %help;
sub help {
my ($action, $type) = @_;
- my (%help, $key);
+ my $key;
# What help topics do we know about?
- local $/ = undef;
- foreach my $item (@{ Form::parse(<DATA>) }) {
- my $title = $item->[2]{Title};
- my @titles = ref $title eq 'ARRAY' ? @$title : $title;
-
- foreach $title (grep $_, @titles) {
- $help{$title} = $item->[2]{Text};
+ if (!%help) {
+ local $/ = undef;
+ foreach my $item (@{ Form::parse(<DATA>) }) {
+ my $title = $item->[2]{Title};
+ my @titles = ref $title eq 'ARRAY' ? @$title : $title;
+
+ foreach $title (@titles) {
+ $help{$title} = $item->[2]{Text};
+ }
}
}
More information about the Rt-commit
mailing list