about summary refs log tree commit diff stats
path: root/leo.pl
diff options
context:
space:
mode:
Diffstat (limited to 'leo.pl')
-rwxr-xr-xleo.pl38
1 files changed, 21 insertions, 17 deletions
diff --git a/leo.pl b/leo.pl
index 9f6482b..3c20e8e 100755
--- a/leo.pl
+++ b/leo.pl
@@ -11,7 +11,7 @@ use Getopt::Long qw/ GetOptions /;
 my %options = ();
 GetOptions(
     \%options,
-    qw{ verbose }
+    qw{ verbose encrypt sign }
 ) or die "Error in command line arguments\n";
 
 
@@ -75,6 +75,9 @@ sub tar_list { run3 ["/bin/tar", "tvf", @_]; }
 
 # Creating tars of files.
 sub archive {
+    my $gpg_fingerprint = "D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD";
+    my $archive_dir = "/tmp/archive";
+
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
         localtime(time);
 
@@ -89,37 +92,30 @@ sub archive {
 
     my %archive_dispatch = (
         "documents" => sub {
-            tar_create("/tmp/archive/documents_$ymd.tar",
+            tar_create("$archive_dir/documents_$ymd.tar",
                        "-C", "$ENV{HOME}/documents", ".");
         },
         "journal" => sub {
-            tar_create("/tmp/archive/journal_$ymd.tar",
+            tar_create("$archive_dir/journal_$ymd.tar",
                        "-C", "$ENV{HOME}/documents",
                        "andinus.org.gpg", "archive.org.gpg");
         },
         "ssh" => sub {
-            tar_create("/tmp/archive/ssh_$ymd.tar",
+            tar_create("$archive_dir/ssh_$ymd.tar",
                        "-C", "$ENV{HOME}/.ssh", ".");
         },
         "pass" => sub {
-            tar_create("/tmp/archive/pass_$ymd.tar",
+            tar_create("$archive_dir/pass_$ymd.tar",
                        "-C", "$ENV{HOME}/.password-store", ".");
         },
     );
 
-    shift @ARGV;
-    if ( $ARGV[0]
-             and $archive_dispatch{ $ARGV[0] } ) {
-        path("/tmp/archive")->mkpath; # Create archive directory.
+    shift @ARGV; # Drop `archive' from @ARGV.
+    if ( $ARGV[0] and $archive_dispatch{ $ARGV[0] } ) {
+        path($archive_dir)->mkpath; # Create archive directory.
         $archive_dispatch{ $ARGV[0] }->();
     } elsif ( scalar @ARGV == 0 ) {
-        archive_HelpMessage();
-    } else {
-        say "leo/archive: no such option";
-    }
-
-    sub archive_HelpMessage {
-        say qq{Archive files to /tmp/archive.
+        say qq{Archive files to $archive_dir.
 
 Usage:
     documents
@@ -130,6 +126,14 @@ Usage:
     ssh
         Archive $ENV{HOME}/.ssh
     pass
-        Archive $ENV{HOME}/.password-store};
+        Archive $ENV{HOME}/.password-store
+
+Options:
+    --encrypt
+        Encrypt files with $gpg_fingerprint
+    --sign
+        Sign files with $gpg_fingerprint};
+    } else {
+        say "leo/archive: no such option";
     }
 }