Ask

 view release on metacpan or  search on metacpan

lib/Ask/Prima.pm  view on Meta::CPAN

use 5.008008;
use strict;
use warnings;

package Ask::Prima;

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

use Moo;
use Prima 1.59 ();
use Path::Tiny 'path';
use namespace::autoclean;

with 'Ask::API';

has application => (
	is      => 'lazy',
	default => sub {
		require Prima::Application;
		require Prima::MsgBox;
		'Prima::Application'->import;
		return 1;
	},
);

sub is_usable {
	my ( $self ) = ( shift );
	return !!$ENV{'DISPLAY'};
}

sub entry {
	my ( $self, %opts ) = ( shift, @_ );
	
	$self->application;
	
	my $return = Prima::MsgBox::input_box(
		$opts{title}   || 'Input',
		$opts{text}    || 'Enter text:',
		$opts{default} || '',
	);
	
	return $return;
} #/ sub entry

sub info {
	my ( $self, %opts ) = ( shift, @_ );
	
	$self->application;
	
	Prima::MsgBox::message_box(
		$opts{title} || 'Info',
		$opts{text},
		mb::Ok | mb::Information,
	);
	
	return;
} #/ sub info

sub warning {
	my ( $self, %opts ) = ( shift, @_ );
	
	$self->application;
	
	Prima::MsgBox::message_box(
		$opts{title} || 'Warning',
		$opts{text},
		mb::Ok | mb::Warning,
	);
	
	return;
} #/ sub warning



( run in 1.317 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )