# Adding new command to axp is easy, you should create one file (or one
# directory for compositive command). No existing files should be changed.
# To add new-command, you may just copy changelog.pm to new_command.pm
# or use this template.
# To test your new command, run "axp new-command --help", "axp new-command".

package AXP::Command::new_command;
use base 'AXP::Command';

use Arch::Util qw(run_tla);

sub infoline {
	"show the version of tla"
}

sub optusage {
	"[options]"
}

sub options {
	(
		full  => { sh => 'f', desc => "show full output" },
		quiet => { sh => 'q', desc => "show no output" },
	)
}

sub helptext {
	q{
		This is just an example command.

		It shows the output of 'tla --version', partial or full
		depending on the options.
	}
}

sub execute {
	my $self = shift;
	my %opt = %{$self->{options}};

	my @output_lines = run_tla("--version");

	if ($opt{full}) {
		print "$_\n" foreach @output_lines;
	} elsif (!$opt{quiet}) {
		print "$output_lines[0]\n";
	}
}

1;
