convert changeIobStatus.pl to module
This commit is contained in:
parent
841b1f60f7
commit
b177bb5c3f
1 changed files with 36 additions and 32 deletions
68
sbin/changeIobStatus.pl → lib/WebGUI/Command/changeIobStatus.pm
Executable file → Normal file
68
sbin/changeIobStatus.pl → lib/WebGUI/Command/changeIobStatus.pm
Executable file → Normal file
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env perl
|
package WebGUI::Command::changeIobStatus;
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
|
@ -10,39 +10,38 @@
|
||||||
# http://www.plainblack.com info@plainblack.com
|
# http://www.plainblack.com info@plainblack.com
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
use WebGUI::Command -command;
|
||||||
use strict;
|
use strict;
|
||||||
use WebGUI::Paths -inc;
|
use warnings;
|
||||||
use Getopt::Long;
|
|
||||||
use Pod::Usage;
|
|
||||||
use WebGUI::Session;
|
|
||||||
use WebGUI::User;
|
|
||||||
use WebGUI::Inbox;
|
|
||||||
|
|
||||||
$|=1;
|
sub opt_spec {
|
||||||
|
return (
|
||||||
|
[ 'configFile=s', 'The WebGUI config file to use. This parameter is required.'],
|
||||||
|
[ 'quiet', q{Disable all output unless there's an error.} ],
|
||||||
|
[ 'whatsHappening:s', q{The message attached to the InOut Board when changing status. If left unspecified it defaults to 'Automatically signed out.'}],
|
||||||
|
[ 'userMessage:s', q{Text of the message to be sent to the user after changing the status. If left unspecified it will default to 'You were logged out of the In/Out Board automatically.'}],
|
||||||
|
[ 'userMessageFile:s', q{Pathname to a file whose contents will be sent to the user after changing the status. Using this option overrides whatever messages is set with --userMessage (see above).}],
|
||||||
|
[ 'currentStatus:s', q{Check users in the IOB having status status. If left unspecified, it will default to In.}],
|
||||||
|
[ 'newStatus:s', q{Change users status in the IOB to status status. If left unspecified, it will default to Out.}],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
my $configFile;
|
sub validate_args {
|
||||||
my $help;
|
my ($self, $opt, $args) = @_;
|
||||||
my $quiet;
|
if (! $opt->{configfile}) {
|
||||||
my $whatsHappening = "Automatically signed out.";
|
$self->usage_error('You must specify the --configFile option.');
|
||||||
my $newStatus = "Out";
|
}
|
||||||
my $currentStatus = "In";
|
}
|
||||||
my $userMessage = "You were logged out of the In/Out Board automatically.";
|
|
||||||
my $userMessageFile;
|
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, $opt, $args) = @_;
|
||||||
|
|
||||||
GetOptions(
|
my ($configFile, $help, $quiet, $whatsHappening, $newStatus, $currentStatus, $userMessage, $userMessageFile) =
|
||||||
'configfile=s'=>\$configFile,
|
@{$opt}{qw(configfile help quiet whatshappening newstatus currentstatus usermessage usermessagefile)};
|
||||||
'help'=>\$help,
|
$whatsHappening ||= "Automatically signed out.";
|
||||||
'quiet'=>\$quiet,
|
$newStatus ||= "Out";
|
||||||
'whatsHappening:s'=>\$whatsHappening,
|
$currentStatus ||= "In";
|
||||||
'userMessage:s'=>\$userMessage,
|
$userMessage ||= "You were logged out of the In/Out Board automatically.";
|
||||||
'userMessageFile:s'=>\$userMessageFile,
|
|
||||||
'currentStatus:s'=>\$currentStatus,
|
|
||||||
'newStatus:s'=>\$newStatus
|
|
||||||
);
|
|
||||||
|
|
||||||
pod2usage( verbose => 2 ) if $help;
|
|
||||||
pod2usage() unless $configFile;
|
|
||||||
|
|
||||||
print "Starting up...\n" unless ($quiet);
|
print "Starting up...\n" unless ($quiet);
|
||||||
my $session = WebGUI::Session->open($configFile);
|
my $session = WebGUI::Session->open($configFile);
|
||||||
|
|
@ -100,22 +99,26 @@ $session->var->end;
|
||||||
$session->close;
|
$session->close;
|
||||||
print "OK\n" unless ($quiet);
|
print "OK\n" unless ($quiet);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
changeIobStatus - Automate WebGUI's InOut Board User status switching.
|
WebGUI::Command::changeIobStatus - Automate WebGUI's InOut Board User status switching.
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
changeIobStatus --configFile config.conf
|
webgui.pl changeiobstatus --configFile config.conf
|
||||||
[--currentStatus status]
|
[--currentStatus status]
|
||||||
[--newStatus status]
|
[--newStatus status]
|
||||||
[--userMessage text|--userMessageFile pathname]
|
[--userMessage text|--userMessageFile pathname]
|
||||||
[--whatsHappening text]
|
[--whatsHappening text]
|
||||||
[--quiet]
|
[--quiet]
|
||||||
|
|
||||||
changeIobStatus --help
|
webgui.pl changeiobstatus --help
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
|
@ -177,3 +180,4 @@ Shows this documentation, then exits.
|
||||||
Copyright 2001-2009 Plain Black Corporation.
|
Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue