diff options
author | Tatsuhiko Miyagawa <miyagawa@bulknews.net> | 2013-06-05 14:59:33 +0900 |
---|---|---|
committer | Tatsuhiko Miyagawa <miyagawa@bulknews.net> | 2013-06-05 14:59:33 +0900 |
commit | 0a26b6729b8d2ddd65a6c9e1270b18c3ea6e2d11 (patch) | |
tree | 0a3dae5fc700437ef2c15d3139dda111abd36cd2 /xt/CLI.pm | |
parent | 9faaae25f5d1c857fbfedfd5bd84088cf142ad38 (diff) | |
download | carton-0a26b6729b8d2ddd65a6c9e1270b18c3ea6e2d11.tar.gz |
refactor CLI with Moo
Diffstat (limited to 'xt/CLI.pm')
-rw-r--r-- | xt/CLI.pm | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -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 { |