App-Chit

 view release on metacpan or  search on metacpan

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

}

sub opt_spec {
	return (
		[ "temperature=f", "temperature for response" ],
		[ "stdin",         "prompt from STDIN" ],
		[ "file=s",        "prompt from file" ],
	);
}

sub validate_args ( $self, $opt, $args ) {
	unless ( $opt->{stdin} or $opt->{file} ) {
		$self->usage_error( "expected a prompt on the command line, or -i, or -f" )
			unless ( @$args == 1 and length($args->[0]) > 2 );
	}
	
	$self->usage_error( "cannot use both -i and -f" )
		if ( $opt->{stdin} and $opt->{file} );
}

sub execute ( $self, $opt, $args ) {

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


sub opt_spec {
	return (
		[ "clean|c",    "use a clean slate" ],
		[ "autofork|a", "fork existing chat from up level directory" ],
		[ "fork|f=s",   "fork existing chat from specified directory" ],
		[ "overwrite",  "overwrite current configuration" ],
	);
}

sub validate_args ( $self, $opt, $args ) {
	exists $opt->{clean}
		or exists $opt->{autofork}
		or exists $opt->{fork}
		or $self->usage_error( "need one of --clean, --autofork, or --fork" );
}

sub execute ( $self, $opt, $args ) {
	my $dir = path( getcwd );
	
	if ( App::Chit::Util::is_chit_dir( $dir ) ) {

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

}

sub opt_spec {
	return (
		[ "msg|n=i",   "number of messages (default 20)" ],
		[ "colour|c",  "force colour" ],
		[ "nocolour",  "avoid colour" ],
	);
}

sub validate_args ( $self, $opt, $args ) {
	$opt->{msg} //= 20;
	$self->usage_error( "expected a positive number" )
		unless $opt->{msg} > 0;
	
	$opt->{colour} //= ( -t STDOUT );
	delete $opt->{colour} if $opt->{nocolour} || $ENV{NO_COLOR};
}

sub execute ( $self, $opt, $args ) {
	my $dir = App::Chit::Util::find_chit_dir()

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

sub abstract {
	return "Show or set the temperature for this chat."
}

sub opt_spec {
	return (
		[ "set=f",      "set temperature (decimal number from 0.0 to 2.0)" ],
	);
}

sub validate_args ( $self, $opt, $args ) {
	if ( exists $opt->{set} ) {
		$self->usage_error( "too hot" ) if $opt->{set} > 2;
		$self->usage_error( "too cold" ) if $opt->{set} < 0;
	}
}

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 );



( run in 1.268 second using v1.01-cache-2.11-cpan-140bd7fdf52 )