App-rdapper
view release on metacpan or search on metacpan
lib/App/rdapper.pm view on Meta::CPAN
foreach my $type ($object->dns_ttl_types) {
$package->print_kv($type, _('[_1]s', $object->dns_ttl($type)), 1+$indent);
}
foreach my $remark ($object->dns_ttl_remarks) {
$package->print_remark_or_notice($remark, 1+$indent);
}
}
sub print_kv {
my ($package, $name, $value, $indent) = @_;
$out->print(wrap(
(INDENT x $indent),
(INDENT x ($indent + 1)),
sprintf("%s %s\n", b($name.':'), $value),
));
}
sub debug {
my ($package, $fmt, @params) = @_;
if ($debug) {
my $str = sprintf(_("Debug: [_1]", $fmt), @params);
$err->say(colourise([qw(magenta)], $str));
}
}
sub info {
my ($package, $fmt, @params) = @_;
my $str = sprintf(_("Info: [_1]", $fmt), @params);
$err->say(colourise([qw(cyan)], $str));
}
sub warning {
my ($package, $fmt, @params) = @_;
my $str = sprintf(_("Warning: [_1]", $fmt), @params);
$err->say(colourise([qw(yellow)], $str));
}
sub error {
my ($package, $fmt, @params) = @_;
my $str = sprintf(_("Error: [_1]", $fmt), @params);
$err->say(colourise([qw(red)], $str));
exit 1;
}
sub colourise {
my ($cref, $str) = @_;
if (-t $out && !$nocolor) {
return colored($cref, $str);
} else {
return $str;
}
}
sub u { colourise([qw(underline)], shift) }
sub b { colourise([qw(bold)], shift) }
sub _ { decode($LH->encoding, $LH->maketext(@_)) }
#
# this function uses PPI to parse this file, extract the messages passed to _()
# and prints a .po file on STDOUT.
#
sub export_strings {
eval {
require PPI;
my $doc = PPI::Document->new(__FILE__);
$doc->prune(q{PPI::Token::Comment});
$doc->prune(q{PPI::Token::Whitespace});
my @msgs;
my @nodes = @{$doc->find(sub { 1 })};
for (my $i = 0 ; $i < scalar(@nodes) ; $i++) {
my $node = $nodes[$i];
if ($node->isa(q{PPI::Token::Magic}) && q{_} eq $node->content) {
my $next = $nodes[$i+1];
if ($next->isa(q{PPI::Structure::List})) {
my $msg = ($next->tokens)[1];
if (!$msg->isa(q{PPI::Token::Quote})) {
die(sprintf(
"%s: first argument to _() must be a string literal",
$msg->content,
));
}
push(@msgs, $msg->string);
}
}
}
foreach my $msg (uniq(@msgs)) {
printf("msgid \"%s\"\nmsgstr \"\"\n\n", $msg);
}
};
exit;
}
sub encode_idn {
my ($package, $name) = @_;
return Net::IDN::PP->encode($name);
}
1;
__END__
=pod
=head1 NAME
App::rdapper - a command-line L<RDAP|https://about.rdap.org> client.
( run in 0.734 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )