App-Chit

 view release on metacpan or  search on metacpan

lib/App/Chit/Command/maxhistory.pm  view on Meta::CPAN

use v5.20;
use strict;
use warnings;
use experimental qw( signatures lexical_subs postderef );

package App::Chit::Command::maxhistory;

use App::Chit -command;

use App::Chit::Util ();

our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION   = '0.001001';

sub abstract {
	return "Show or set the current maximum chat history length."
}

sub opt_spec {
	return (
		[ "set=i",      "set maximum chat history length" ],
	);
}

sub execute ( $self, $opt, $args ) {
	my $dir = App::Chit::Util::find_chit_dir()
		or $self->usage_error("need to initialize chit first");
	my $chit = App::Chit::Util::load_chit( $dir );
	
	if ( length $opt->{set} ) {
		say "Previous maximum history length:   ", int( 0 + $chit->{history} );
		say "Setting maximum history length to: ", $opt->{set};
		$chit->{history} = $opt->{set};
	}
	else {
		say int( 0 + $chit->{history} );
	}
	
	App::Chit::Util::save_chit( $dir, $chit );
}

1;



( run in 1.489 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )