use of xml in perl application to describe command line logic
am 20.12.2005 20:03:43 von strepxe
Hi,
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].
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).
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.
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.
g
Re: use of xml in perl application to describe command line logic
am 21.12.2005 16:34:12 von metaperl
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
Re: use of xml in perl application to describe command line logic
am 21.12.2005 23:58:40 von Ron Savage
On Thu, 22 Dec 2005 02:34:12 +1100, metaperl@gmail.com wrote:
Hi
Also, consider processing your XML file of options with a module such as
Config::General. There are many config modules available, and although
Config::General's docs discuss many options and make the module look=
complex, it
is actually a very nice module to use.