|
Posted by metaperl@gmail.com on December 21, 2005, 7:34 am
Please log in for more thread options
strepxe@yahoo.co.uk wrote:
> Hi,
Hi, I think you need base classes and derived classes for this problem:
> I work for a compay which sells a unix-based product comprising several
> binaries. The binaries have numerous command line options which change
> with version releases [immutable facts].
let's just say you have the binaries jkapp and mqapp
package Cmdline::jkapp;
sub required_options {
...
}
sub optional_options {
...
}
1;
package Cmdline::jkapp::v5;
use base Cmdline::jkapp;
sub required_options {
my $self = shift;
my $options = $self->SUPER::required_options;
$options->{tweak => 'this', alter => 'that';
$options
}
>
> We use shell scripts to control the binaries startup and shutown. It
> does, unfortuately involve lots of modifications for each release
> because of the increasingly complicated command line options (some of
> which are mandatory, others are not).
yes, your base class has the default mandataory and optional options in
the subs (as shown above) and each version derives from base and
modifies the two subroutines as necessary.
>
> I want to use perl to write an application which can manage the
> execution of these processes. What I'm wondering is if anyone out there
> has ever created a configuration file to describe the logic of command
> line options for binaries or similar; I want to have a configuration
> file I can modify rather than code in the utility I produce.
What you want is in between the two. Some good configuration packages
allow for merges and over-rides, but why compromise. On the other hand,
you are also right - don't write a lot of dynamic code for this either.
>
> Any assistance on this would be greatly appreciated. This is my first
> posting on the topic but I will add more information if anyone needs
> further information about my problem.
you might also ask on perlmonks.org, but I have given you what I feel
is a workable solution... keep us posted on your progress!
>
> g
|