1 package Email::EzPz::ListCore;
5 use Capture::Tiny qw(capture_merged);
6 use IPC::System::Simple qw(run capture);
8 has list_dir => (is => 'ro', required => 1);
10 has ezmlm_bindir => (is => 'ro', required => 1);
12 requires 'sublist_type';
15 my ($self, $command) = @_;
16 if (ref(my $bindir = $self->ezmlm_bindir) eq 'ARRAY') { # prefix list
17 return (@{$bindir}, "ezmlm-${command}");
19 return io->dir($bindir)->catfile("ezmlm-${command}");
24 my ($self, $command, @args) = @_;
26 $self->_command_path($command),
34 my ($self, @cmd) = @_;
36 my $out = capture_merged {
37 $ok = eval { run $self->_command_args(@cmd); 1 };
39 die "Command failed: $out\n" unless $ok;
43 sub _capture_command {
44 my ($self, @cmd) = @_;
45 map { chomp; $_ } capture $self->_command_args(@cmd);
49 my ($self, $member) = @_;
50 $self->_call_command(sub => $member);
55 my ($self, $member) = @_;
56 $self->_call_command(unsub => $member);
62 $self->_capture_command('list');