Subject: | flexible nopaste() arguments... |
I thought I posted this patch before but I can't find any record of it in
RT so if this is a repeat just yell at me and I'll shut-up.
I've recently found my self subclassing App::Nopaste::Command in
conjunction with building in house service classes that require
additional configurable command line/config file parameters.
This patch allows a service class to pick up on new command line
(configfile) options from a sub-classed A:N::Command class via slurping
in attributes from the command class.
Thanks,
- Jason
Subject: | args_from_meta_attr-0.19.patch |
--- lib/App/Nopaste/Command.pm.orig 2010-01-14 20:11:25.371820437 -0800
+++ lib/App/Nopaste/Command.pm 2010-01-15 12:12:16.341450366 -0800
@@ -71,17 +71,13 @@
sub run {
my $self = shift;
- my $text = $self->read_text;
-
- my %args = (
- text => $text,
- desc => $self->desc,
- nick => $self->nick,
- lang => $self->lang,
- chan => $self->chan,
- services => $self->services,
- );
+ my %args = map {
+ $_->name => $_->get_value($self)
+ } $self->meta->get_all_attributes;
+
+ $args{text} ||= $self->read_text;
+
$args{error_handler} = $args{warn_handler} = sub { }
if $self->quiet;