package Getopt::Dakkar::Style; use 5.026; use strictures version => 2; use true; use Import::Into; use Path::Tiny (); # VERSION # ABSTRACT: simplify writing things in the right style sub use_types { my ($caller) = @_; require Types::Standard; require Type::Params; Types::Standard->import::into( $caller, "Any", "Item", "Bool", "Undef", "Defined", "Value", "Str", "Num", "Int", "ClassName", "RoleName", "Ref", "CodeRef", "RegexpRef", "FileHandle", "ArrayRef", "HashRef", "ScalarRef", "Object", "Maybe", "Map", "Optional", "Tuple", "Dict", "InstanceOf", "ConsumerOf", "HasMethods", ); Type::Params->import::into($caller); } sub import { my $class = shift; my (@args) = @_; my $caller = caller(); strict->import(); feature->import::into($caller, ':5.26'); Try::Tiny->import::into($caller); Carp->import::into($caller); true->import({ into => $caller }); Getopt::Dakkar::X->import::into($caller); my %arg = map { $_ => 1 } @args; if ($arg{class}) { require Moo; Moo->import::into($caller); $arg{types}=1; } if ($arg{role}) { require Moo::Role; Moo::Role->import::into($caller); $arg{types}=1; } if ($arg{types}) { use_types($caller); } if ($arg{test}) { require Test::Most; require Test::Warnings; require lib; Test::Most->import::into($caller); Test::Warnings->import::into($caller); lib->import::into( $caller, Path::Tiny::path(__FILE__)->parent(4)->child('t/lib')->stringify, ); } # This must come after anything else that might change warning # levels in the caller (e.g. Moo) strictures->import::into($caller,version=>2); # and then we disable warnings for the experimental features we # want experimental->import::into($caller,qw(postderef signatures)); # Auto-clean up imported symbols namespace::autoclean->import( -cleanee => $caller, ); return; }