App-orgadb

 view release on metacpan or  search on metacpan

script/orgadb-sel  view on Meta::CPAN

 ** 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
 ...
 > select lisa -l
 ...
 > select lisa cell -E -N
 ...
 > exit

 % _

When the addressbook files change on disk, the files will be re-read.

=head2 Password book

Aside from a regular addressbook, you can also use B<orgadb-sel> with password
books (a file you store passwords in). B<orgadb-sel> can read GnuPG-encrypted
files, where the decrypted content is read into memory and not stored in
temporary files. You can then use shell mode (C<-s>) to repeatedly query the
password book without re-reading and re-decrypting everytime. For example,
suppose you have a password book like this:

 # -*- Mode: org -*-
 * persona > perlancar
 ** google (perlancar)
 - username :: perlancar
 - pass :: secret1
 - security question :: favorite dog in the whole wide world?
 - security answer :: impossible to pick one
 - log ::
   + [2022-07-04 Mon] :: change password
   + [2017-08-01] :: create
 ** twitter (perlancar)
 - username :: perlancar
 - pass :: secret2
 * persona > steven
 ** google (steven123123)
 - username :: steven123123
 - phone :: 555-123-2345
 - pass :: secret3

and you store it in C<~/passwords.gpg>. Then to query passwords:

 # What's my (perlancar)'s google password?
 % orgadb-sel -f ~/passwords.gpg /google.+perlancar/ pass -EN
 secret1

 # What's my (steven)'s phone used in the google account?
 % orgadb-sel -f ~/passwords.gpg /google.+steven/ '/phone|cell/' -EN
 555-123-2345

Or, in shell mode:

 % 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

=item * orgadb-sel

CLI to list/select addressbook entries and fields.

=back

The addressbook must be written following a certain structure, as shown in the
Synopsis. The first heading level is for putting categories. The second heading
level is where you put all your entries. Fields are written in description list.

=head1 TIPS AND TRICKS

=head2 Aliasing orgadb-sel to a shorter command name

If you are like me and you select from addressbooks a lot, you might want to
alias C<orgadb-sel> to a shorter name, e.g. C<sel>. To do this, create this
script somewhere in your PATH:

 #!/usr/bin/env perl
 # FRAGMENT id=shcompgen-hint command=orgadb-sel
 exec "orgadb-sel", @ARGV;

The C<# FRAGMENT> line is optional (it's useful if you use L<shcompgen>). In
your bash startup file, put something like:

 complete -C orgadb-sel sel

or if you L<shcompgen>, run C<shcompgen gen sel> instead.

=head2 Tab completion

The script provides tab completion for category, entry, and field, so you can
type:

 % orgadb-sel --category <tab>        ;# see what categories are available
 % orgadb-sel lis<tab>                ;# complete with entries matching 'lis'
 % orgadb-sel lisa <tab>              ;# complete with available fields of /lisa/ entries

=head2 Using field formatters

Suppose you want to format phone number using international notation:

 % orgadb-sel lisa phone -f Phone::format

=head2 Using default field formatter rules

Instead of specifying formatters everytime, you can setup rules for default
formatters in the configuration file:

 default_formatter_rules={"hide_field_name":true, "formatters":["Str::remove_comment"]}
 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"]}



( run in 0.603 second using v1.01-cache-2.11-cpan-df04353d9ac )