view release on metacpan or search on metacpan
0.014 2022-10-17 Released-By: PERLANCAR; Urgency: medium
- Add shortcut options: --remove-nondigits,
--remove-comments, --remove-whitespaces, --format-phone.
- [bugfix] Non-simple headings (e.g. containing timestamp) were not
matched.
- [doc] Add mnenomic note for -N, -l.
- [ux] Add shortcut option -y for --clipboard=tee, and -Y for
--clipboard=only.
0.013 2022-10-16 Released-By: PERLANCAR; Backward-Incompatible: yes
- [incompatible change] Rename --formatter to --field-value-formatter
(alias --fvfmt) to avoid ambiguity with --format. Also,
--no-formatters becomes --no-field-value-formatters,
--default-formatter-rules becomes --field-value-formatter-rules.
- [bugfix][doc] Usage line didn't yet include common options.
- No functional changes.
- Fix typos in documentation.
- [build] Rebuild to improve generated POD.
0.011 2022-10-15 Released-By: PERLANCAR; Urgency: medium
- Add --clipboard option.
- [doc] Show complete usage line in POD.
- Improve default formatting rules: add condition key 'hide_field_name',
all rules are now evaluated and all formatters from matching, expand
docs.
0.010 2022-10-09 Released-By: PERLANCAR; Urgency: medium
- [bugfix] We were repeatedly forming regex from string
Select Org addressbook entries/fields/subfields.
This function is not exported.
Arguments ('*' denotes required arguments):
* category => *str_or_re*
Find entry by string or regex search against the category title.
* clipboard => *str*
Whether to copy matching field values to clipboard.
If set to "tee", then will display matching fields to terminal as
well as copy matching field values to clipboard.
If set to "only", then will not display matching fields to terminal
and will only copy matching field values to clipboard.
Mnemonic for short option "-y" and "-Y": *y*ank as in Emacs ("C-y").
* color => *str* (default: "auto")
Whether to use color.
* color_theme => *perl::colortheme::modname_with_optional_args*
(No description)
lib/App/orgadb.pm view on Meta::CPAN
} elsif (@matching_fields) {
for my $field (@matching_fields) {
my $field_name0 = $field->desc_term->text;
unless ($args{hide_field_name}) {
my $field_name = '';
$field_name = _highlight(
$clrtheme_obj,
$re_field,
$field->bullet . ' ' . $field_name0,
) . " ::";
unless ($args{clipboard} && $args{clipboard} eq 'only') {
$res->[2] .= $field_name;
}
}
my $field_value_formatter_from_rules;
my $field_value_formatter_filters_from_rules;
SET_FIELD_VALUE_FORMATTERS_FROM_RULES:
{
last if $args{no_field_value_formatters};
last if $field_value_formatter_from_args;
lib/App/orgadb.pm view on Meta::CPAN
}
if ($field_value_formatter) {
my ($ferr, $fres) = @{ $field_value_formatter->($field_value) };
if ($ferr) {
log_warn "Field value formatting error: formatter=%s, field value=%s, errmsg=%s", $field_value_formatter_filters, $field_value, $ferr;
$field_value = "$field_value # CAN'T FORMAT: $ferr";
} else {
$field_value = $fres;
}
}
unless ($args{clipboard} && $args{clipboard} eq 'only') {
$res->[2] .= ($args{hide_field_name} ? "" : $prefix) . $field_value . $suffix;
}
push @outputted_field_values, $field_value;
}
}
}
}
COPY_TO_CLIPBOARD: {
last unless $args{clipboard};
last unless @outputted_field_values;
require Clipboard::Any;
log_info "Copying matching field values to clipboard ...";
my $res = Clipboard::Any::add_clipboard_content(content => join "\n", @outputted_field_values);
if ($res->[0] != 200) {
log_warn "Cannot copy to clipboard: $res->[0] - $res->[1]";
last;
}
}
$res;
}
sub _select_shell {
my %args = @_;
lib/App/orgadb.pm view on Meta::CPAN
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<category> => I<str_or_re>
Find entry by string or regex search against the category title.
=item * B<clipboard> => I<str>
Whether to copy matching field values to clipboard.
If set to C<tee>, then will display matching fields to terminal as well as copy
matching field values to clipboard.
If set to C<only>, then will not display matching fields to terminal and will
only copy matching field values to clipboard.
Mnemonic for short option C<-y> and C<-Y>: I<y>ank as in Emacs (C<C-y>).
=item * B<color> => I<str> (default: "auto")
Whether to use color.
=item * B<color_theme> => I<perl::colortheme::modname_with_optional_args>
(No description)
lib/App/orgadb/Common.pm view on Meta::CPAN
num_fields => {
summary => 'Specify maximum number of fields (per entry) to return (0 means unlimited)',
schema => 'uint*',
cmdline_aliases => {
n=>{},
1 => {is_flag=>1, summary=>'Shortcut for --num-fields=1', code=>sub { $_[0]{num_fields} = 1 }},
},
tags => ['category:output'],
},
clipboard => {
summary => 'Whether to copy matching field values to clipboard',
schema => ['str*', in=>[qw/tee only/]],
description => <<'MARKDOWN',
If set to `tee`, then will display matching fields to terminal as well as copy
matching field values to clipboard.
If set to `only`, then will not display matching fields to terminal and will
only copy matching field values to clipboard.
Mnemonic for short option `-y` and `-Y`: *y*ank as in Emacs (`C-y`).
MARKDOWN
cmdline_aliases => {
clipboard_only => {is_flag=>1, summary=>'Shortcut for --clipboard=only', code=>sub { $_[0]{clipboard} = 'only' }},
y => {is_flag=>1, summary=>'Shortcut for --clipboard=tee', code=>sub { $_[0]{clipboard} = 'tee' }},
Y => {is_flag=>1, summary=>'Shortcut for --clipboard=only', code=>sub { $_[0]{clipboard} = 'only' }},
},
tags => ['category:output'],
},
);
1;
# ABSTRACT:
__END__
lib/App/orgadb/Select/Shell/Commands.pm view on Meta::CPAN
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<category> => I<str_or_re>
Find entry by string or regex search against the category title.
=item * B<clipboard> => I<str>
Whether to copy matching field values to clipboard.
If set to C<tee>, then will display matching fields to terminal as well as copy
matching field values to clipboard.
If set to C<only>, then will not display matching fields to terminal and will
only copy matching field values to clipboard.
Mnemonic for short option C<-y> and C<-Y>: I<y>ank as in Emacs (C<C-y>).
=item * B<count> => I<true>
Return just the number of matching entries instead of showing them.
=item * B<detail> => I<bool>
Instead of showing matching field values, display the whole entry.
script/orgadb-sel view on Meta::CPAN
=head1 NAME
orgadb-sel - Select entries and fields from Org addressbook
=head1 VERSION
This document describes version 0.020 of orgadb-sel (from Perl distribution App-orgadb), released on 2025-06-19.
=head1 SYNOPSIS
B<B<orgadb-sel>> [B<L<--category|/"--category=s, -c">>=I<L<str_or_re|Sah::Schema::str_or_re>>|B<L<-c|/"--category=s, -c">>=I<L<str_or_re|Sah::Schema::str_or_re>>] [B<L<--clipboard|/"-y">>=I<str>|B<L<-Y|/"-y">>|B<L<--clipboard-only|/"-y">>|B<L<-y|/"-y...
First, create a configuration file F<~/.config/orgadb.conf> containing something
like the following (use INI syntax, or L<IOD> to be more exact):
; specify your addressbook files here
files = ~/addressbook.org
files = /path/to/another-addressbook.org
Suppose you have F<~/addressbook.org> like the following (entries are written as
level-2 headings, level 1 is used for categories, hierarchical categories can be
script/orgadb-sel view on Meta::CPAN
% orgadb-sel iwan address postcode -EN
40123
=head2 Formatting
You can apply one or more formatters to field values:
% orgadb-sel lisa cell --formatter Str::remove_non_digit -EN
5551234710
=head2 Copying to clipboard
Instead of just displaying result to terminal, you can instruct to also copy
matching field values to clipboard with the `--clipboard=tee` (`-y`) option:
% orgadb-sel lisa cell -y
** work > newsradio/lisa
- cell :: 555-1234-710
(and clipboard will contain C<555-1234-710>).
You can also instruct to only output matching field values to clipboard and not
print matching fields to terminal using the `--clipboard=only` (`-Y`) option:
% orgadb-sel lisa cell -Y
** work > newsradio/lisa
(and clipboard will contain C<555-1234-710>).
=head2 Shell mode
Instead of selecting one time and exiting, you can instruct B<orgadb-sel> to
enter shell mode, where you can issue multiple select commands without
re-reading the Org addressbook files repeatedly. For example:
% orgadb-sel -s
> select lisa
...
script/orgadb-sel view on Meta::CPAN
% orgadb-sel -f ~/passwords.gpg -s
> select /google.+perlancar/ pass -EN
secret1
> select /google.+steven/ '/phone|cell/' -EN
555-123-2345
> exit
% _
The C<--clipboard=only> (C<-Y>) option is handy when querying password book; you
can choose to output field values only to clipboard instead of to terminal:
# What's my (perlancar)'s google password?
% orgadb-sel -f ~/passwords.gpg /google.+perlancar/ pass -EN -Y
=head1 DESCRIPTION
B<App::orgadb> is a set of CLIs for addressbook written in Org format. It
currently contains:
=over
script/orgadb-sel view on Meta::CPAN
default_formatter_rules={"field_name_matches":"/te?lp|wa|phone|whatsapp|hp/i","hide_field_name":true, "formatters":["Phone::format_idn_nospace"]}
default_formatter_rules={"field_name_matches":"/te?lp|wa|phone|whatsapp|hp/i","hide_field_name":false, "formatters":["Phone::format_idn"]}
and after this, when you select they will automatically be applied when
selecting matching fields:
% orgadb-sel lisa phone
To disable formatters, use C<--no-formatters> (C<-F>).
=head2 Copying to clipboard
Instead of manually copy-pasting the result of C<orgadb-sel> using your mouse in
the terminal and pasting to other GUI application (like LibreOffice Writer/Calc,
WhatsApp Web in Firefox, or whatever), you can instruct C<orgadb-sel> to copy to
clipboard for you:
% orgadb-sel -c lisa phone
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
script/orgadb-sel view on Meta::CPAN
(No description)
=back
=head2 Output options
=over
=item B<--clipboard-only>
Shortcut for --clipboard=only.
See C<--clipboard>.
=item B<--clipboard>=I<s>
Whether to copy matching field values to clipboard.
Valid values:
["tee","only"]
If set to C<tee>, then will display matching fields to terminal as well as copy
matching field values to clipboard.
If set to C<only>, then will not display matching fields to terminal and will
only copy matching field values to clipboard.
Mnemonic for short option C<-y> and C<-Y>: I<y>ank as in Emacs (C<C-y>).
=item B<--detail>, B<-l>
Instead of showing matching field values, display the whole entry.
Mnemonic for shortcut option C<-l>: the option C<-l> is usually used for the short
version of C<--detail>, as in I<ls> Unix command.
script/orgadb-sel view on Meta::CPAN
=item B<-1>
Shortcut for --num-fields=1.
See C<--num-fields>.
=item B<-Y>
Shortcut for --clipboard=only.
See C<--clipboard>.
=item B<-y>
Shortcut for --clipboard=tee.
See C<--clipboard>.
=back
=head2 Other options
=over
=item B<--help>, B<-h>, B<-?>
Display help message and exit.
script/orgadb-sel view on Meta::CPAN
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
category (see --category)
clipboard (see --clipboard)
color (see --color)
color_theme (see --color-theme)
count (see --count)
detail (see --detail)
entry (see --entry)
entry_match_mode (see --entry-match-mode)
field_match_mode (see --field-match-mode)
field_value_formatter_rules (see --field-value-formatter-rules)
field_value_formatters (see --field-value-formatter)
fields (see --field)