App-orgadb
view release on metacpan or search on metacpan
lib/App/orgadb.pm view on Meta::CPAN
}
$res;
}
sub _select_shell {
my %args = @_;
require App::orgadb::Select::Shell;
my $shell = App::orgadb::Select::Shell->new(
main_args => \%args,
);
$shell->cmdloop;
[200];
}
$SPEC{select} = {
v => 1.1,
summary => 'Select Org addressbook entries/fields/subfields',
args => {
%App::orgadb::Common::argspecs_common,
%App::orgadb::Common::argspecs_select,
},
'x.envs' => {
'ORGADB_COLOR_THEME' => {
summary => 'Set default color theme',
schema => 'perl::colortheme::modname_with_optional_args*',
description => <<'MARKDOWN',
Color theme is Perl module name under the `ColorTheme::Search::` namespace,
without the namespace prefix. The default is `Light`. You can set color theme
using the `--color-theme` command-line option as well as this environment
variable.
MARKDOWN
},
},
};
sub select {
my %args = @_;
return [400, "Please specify at least one file"] unless @{ $args{files} || [] };
my $code_parse_files = sub {
my @filenames = @_;
my @trees;
my @tree_filenames;
require Org::Parser;
my $parser = Org::Parser->new;
for my $filename (@filenames) {
my $doc;
if ($filename eq '-') {
binmode STDIN, ":encoding(utf8)";
$doc = $parser->parse(join "", <>);
} else {
local $ENV{PERL_ORG_PARSER_CACHE} = $ENV{PERL_ORG_PARSER_CACHE} // 1;
if ($filename =~ /\.gpg\z/) {
require IPC::System::Options;
my $content;
IPC::System::Options::system(
{log=>1, capture_stdout=>\$content, die=>1},
"gpg", "-d", $filename);
$doc = $parser->parse($content);
} else {
$doc = $parser->parse_file($filename);
}
}
push @trees, $doc;
push @tree_filenames, $filename;
} # for filename
return (\@trees, \@tree_filenames);
};
if ($args{shell}) {
_select_shell(
_code_parse_files => $code_parse_files,
%args,
);
} else {
my ($trees, $tree_filenames) = $code_parse_files->(@{ $args{files} });
_select_single(
%args,
_trees => $trees,
_tree_filenames => $tree_filenames,
);
}
}
1;
# ABSTRACT: An opinionated Org addressbook toolset
__END__
=pod
=encoding UTF-8
=head1 NAME
App::orgadb - An opinionated Org addressbook toolset
=head1 VERSION
This document describes version 0.020 of App::orgadb (from Perl distribution App-orgadb), released on 2025-06-19.
=head1 SYNOPSIS
=head1 DESCRIPTION
This distribution includes the following CLI's:
=over
=item * L<orgadb-sel>
=back
=head1 FUNCTIONS
=head2 select
( run in 2.132 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )