NAME
IPC::PrettyPipe::Arg - An argument to an IPC::PrettyPipe::Cmd command
VERSION
version 0.13
SYNOPSIS
use
IPC::PrettyPipe::Arg;
# standard constructor
$arg
= IPC::PrettyPipe::Arg->new(
name
=>
$name
,
value
=>
$value
,
%attr
);
# concise constructors
$arg
= IPC::PrettyPipe::Arg->new(
$name
);
$arg
= IPC::PrettyPipe::Arg->new( [
$name
,
$value
] );
# perform value substitution
$arg
->valsubst(
$pattern
,
$rep
);
# return a rendered argument
$arg
->render;
DESCRIPTION
IPC::PrettyPipe::Arg objects are containers for arguments to commands in an IPC::PrettyPipe::Cmd object.
METHODS
- new
-
# named parameters; may provide additional attributes
$arg
= IPC::PrettyPipe::Arg->new( \
%attr
);
# concise interface
$arg
= IPC::PrettyPipe::Arg->new(
$name
);
# switch arg
$arg
= IPC::PrettyPipe::Arg->new( [
$name
,
$value
] );
# arg w/ value
The available attributes are:
name
-
Required. The name of the argument.
value
-
The value of the argument. If an argument is a switch, no value is required.
pfx
-
A string prefix to be applied to the argument name before being rendered. This is often
-
or--
.A prefix is not required (the argument name may already have it). This attribute is useful when creating arguments from hashes where the keys do not contain a prefix.
sep
-
A string to insert between the argument name and value when rendering. In some cases arguments must be a single string where the name and value are separated with an
=
character; in other cases they are treated as separate entities. Ifsep
isundef
it indicates that they are treated as separate entities. It defaults toundef
.
- pfx
-
$current_value
=
$self
->pfx;
$self
->pfx(
$new_value
);
Get or set the value of the
pfx
attribute. - sep
-
$current_value
=
$self
->sep;
$self
->sep(
$new_value
);
Get or set the value of the
sep
attribute. - name
-
$name
=
$self
->name;
The argument's name;
- quoted_name
-
$name
=
$self
->quoted_name;
The argument's name, appropriately quoted for passing as a single word to a Bourne compatible shell.
- value
-
$value
=
$self
->value;
The argument's value;
- quoted_value
-
$value
=
$self
->quoted_value;
The argument's value, appropriately quoted for passing as a single word to a Bourne compatible shell.
- has_value
-
$bool
=
$self
->has_value
Returns true if the argument has been assigned a value.
- has_blank_value
-
$bool
=
$self
->has_blank_value
Returns true if the value is the empty string.
- render
-
@rendered_arg
=
$arg
->render;
Render the argument. If the argument's
sep
attribute is defined, render returns a string which looks like:$pfx
.
$name
.
$sep
.
$value
If
sep
is not defined, it returns an array ref which looks like$pfx
.
$name
,
$value
- valmatch
-
$bool
=
$arg
->valmatch(
$pattern
);
Returns true if the argument has a value and it matches the passed regular expression.
- valsubst
-
$arg
->valsubst(
$pattern
,
$rep
);
If the argument has a value, perform the equivalent to
$value
=~ s/
$pattern
/
$rep
/;
SUPPORT
Bugs
Please report any bugs or feature requests to bug-ipc-prettypipe@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=IPC-PrettyPipe
Source
Source is available at
and may be cloned from
SEE ALSO
Please see those modules/websites for more information related to this module.
AUTHOR
Diab Jerius <djerius@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007