
Smart::Options::Declare - DSL for Smart::Options

use Smart::Options::Declare;
opts my $rif => 'Int', my $xup => 'Num';
if ($rif - 5 * $xup > 7.138) {
say 'Buy more fiffiwobbles';
}
else {
say 'Sell the xupptumblers';
}
# $ ./example.pl --rif=55 --xup=9.52
# Buy more fiffiwobbles
#
# $ ./example.pl --rif 12 --xup 8.1
# Sell the xupptumblers

Smart::Options::Declare is a library which offers DSL for Smart::Options.

set option value to variable.
use Smart::Options::Declare;
opts my $var => 'Str', my $value => { isa => 'Int', default => 4 };
define new type and convert logic.
opts_coerce Time => 'Str', sub { Time::Piece->strptime($_[0]) }
opts my $time => 'Time';
$time->hour;



This subtype is based off of ArrayRef. It will attempt to split any values passed on the command line on a comma: that is,
opts my $foo => 'ArrayRef'; # script.pl --foo=one --foo=two,three # => ['one', 'two,three']
will become
opts my $foo => 'Multiple'; # script.pl --foo=one --foo=two,three # => ['one', 'two', 'three']
Kan Fushihara <kan.fushihara@gmail.com>


Copyright (C) Kan Fushihara
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.