From 78778ce31d566fd19c52f54c6ddea2f8b4ade160 Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 27 Aug 2020 16:11:01 +0530 Subject: Document dispatch table generation --- README | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/README b/README index 1df0bd7..2f52d71 100644 --- a/README +++ b/README @@ -9,9 +9,11 @@ Table of Contents ───────────────── 1 Documentation -.. 1.1 encrypt/sign -.. 1.2 delete -.. 1.3 help +.. 1.1 Dispatch table +.. 1.2 Options +..... 1.2.1 encrypt/sign +..... 1.2.2 delete +..... 1.2.3 help 2 Example 3 History @@ -27,6 +29,13 @@ list. It can encrypt/sign files with gpg2(1). 1 Documentation ═══════════════ + I use this to quickly archive some of my files & copy them to another + computer as a backup. + + +1.1 Dispatch table +────────────────── + `%dispatch' has the pre-defined list. Learn the list directly from `leo.pl', it's self-explanatory. Or check the sub `HelpMessage', it explains what each command does. @@ -36,16 +45,43 @@ list. It can encrypt/sign files with gpg2(1). `YYYY-MM-DD' format. ┌──── │ my %dispatch = ( - │ "documents" => sub { - │ tar_create("/tmp/archive/documents_$ymd.tar", - │ "-C", "$ENV{HOME}/documents", "."); + │ journal => sub { + │ archive("$archive_dir/journal_$ymd.tar", + │ "-C", "$ENV{HOME}/documents", + │ "andinus.org.gpg", "archive.org.gpg"); │ }, │ ... - │ ) + │ ); └──── - I use this to quickly archive some of my files & copy them to another - computer as a backup. + Currently I generate the dispatch table with a function & only special + profiles are added manually like above. `journal' is a special profile + because I don't want encryption on it. + + Other profiles are added by this function: + ┌──── + │ # This adds the directories that have same path relative to $ENV{HOME} + │ # as profile name. + │ foreach my $profile (qw( emails music projects documents .ssh + │ .password-store)) { + │ $dispatch{$profile} = sub { + │ archive("$archive_dir/${profile}_$ymd.tar", + │ "-C", "$ENV{HOME}/$profile", "."); + │ }; + │ } + └──── + + I alias paths like `.ssh' to make it convenient to type: + + ┌──── + │ # Aliases for inconvenient paths. + │ $dispatch{ssh} = $dispatch{".ssh"}; + │ $dispatch{pass} = $dispatch{".password-store"}; + └──── + + +1.2 Options +─────────── Some options can also be passed through environment variables. That allows for configuration in shell rc file & the user can run leo @@ -58,8 +94,8 @@ list. It can encrypt/sign files with gpg2(1). ━━━━━━━━━━━━━━━━━━━━━━ -1.1 encrypt/sign -──────────────── +1.2.1 encrypt/sign +╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ `encrypt_sign' handles `gpg2' related functions. It passes `--yes' by default. @@ -74,15 +110,15 @@ list. It can encrypt/sign files with gpg2(1). `leo --encrypt journal pass' will still encrypt pass. -1.2 delete -────────── +1.2.2 delete +╌╌╌╌╌╌╌╌╌╌╌╌ Removes the archive file after running gpg2(1). This means that either `encrypt' or `sign' option must be passed. -1.3 help -──────── +1.2.3 help +╌╌╌╌╌╌╌╌╌╌ Running just `leo' will print help. -- cgit 1.4.1-2-gfad0