summaryrefslogtreecommitdiff
path: root/xt/CLI.pm
diff options
context:
space:
mode:
authorTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-05 14:59:33 +0900
committerTatsuhiko Miyagawa <miyagawa@bulknews.net>2013-06-05 14:59:33 +0900
commit0a26b6729b8d2ddd65a6c9e1270b18c3ea6e2d11 (patch)
tree0a3dae5fc700437ef2c15d3139dda111abd36cd2 /xt/CLI.pm
parent9faaae25f5d1c857fbfedfd5bd84088cf142ad38 (diff)
downloadcarton-0a26b6729b8d2ddd65a6c9e1270b18c3ea6e2d11.tar.gz
refactor CLI with Moo
Diffstat (limited to 'xt/CLI.pm')
-rw-r--r--xt/CLI.pm26
1 files changed, 10 insertions, 16 deletions
diff --git a/xt/CLI.pm b/xt/CLI.pm
index ad64001..70ce360 100644
--- a/xt/CLI.pm
+++ b/xt/CLI.pm
@@ -21,6 +21,9 @@ extends 'Carton::CLI';
$Carton::CLI::UseSystem = 1;
has dir => (is => 'rw');
+has output => (is => 'rw');
+has system_output => (is => 'rw');
+has system_error => (is => 'rw');
sub print {
my $self = shift;
@@ -29,26 +32,17 @@ sub print {
sub run {
my($self, @args) = @_;
- my $pushd = File::pushd::pushd $self->{dir};
+
+ my $pushd = File::pushd::pushd $self->dir;
+
$self->{output} = '';
- ($self->{system_output}, $self->{system_error}) = capture {
+
+ my @capture = capture {
eval { $self->SUPER::run(@args) };
};
-}
-sub output {
- my $self = shift;
- $self->{output};
-}
-
-sub system_output {
- my $self = shift;
- $self->{system_output};
-}
-
-sub system_error {
- my $self = shift;
- $self->{system_error};
+ $self->system_output($capture[0]);
+ $self->system_error($capture[1]);
}
sub clean_local {