about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-27 18:02:02 +0530
committerAndinus <andinus@nand.sh>2020-08-27 18:02:02 +0530
commit1e63070b73b6950eb4f798f20176a94bff73349d (patch)
tree12d788e18f5cbac51a7ef52bbebcd8ea23fd13b5
parentcb14d4e8506fe1b34c88a02c3008694e242423ea (diff)
downloadleo-1e63070b73b6950eb4f798f20176a94bff73349d.tar.gz
Add help option, update documentation to explain new profiles
-rw-r--r--README54
-rwxr-xr-xleo.pl7
2 files changed, 15 insertions, 46 deletions
diff --git a/README b/README
index 2f52d71..cb1f1fd 100644
--- a/README
+++ b/README
@@ -9,7 +9,7 @@ Table of Contents
 ─────────────────
 
 1 Documentation
-.. 1.1 Dispatch table
+.. 1.1 Profile
 .. 1.2 Options
 ..... 1.2.1 encrypt/sign
 ..... 1.2.2 delete
@@ -33,51 +33,19 @@ list. It can encrypt/sign files with gpg2(1).
   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.
-
-  For example, `documents' will archive `$ENV{HOME}/documents' to
-  `/tmp/archive/documents_$ymd.tar' where `$ymd' is current date in
-  `YYYY-MM-DD' format.
-  ┌────
-  │ my %dispatch = (
-  │     journal => sub {
-  │         archive("$archive_dir/journal_$ymd.tar",
-  │                 "-C", "$ENV{HOME}/documents",
-  │                 "andinus.org.gpg", "archive.org.gpg");
-  │     },
-  │     ...
-  │ );
-  └────
-
-  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.
+1.1 Profile
+───────────
 
-  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", ".");
-  │     };
-  │ }
-  └────
+  Profile is a simple hash table which contains the list of profiles.
+  The profiles are mapped to a list of file paths relative to `$HOME'
+  which are to be archived.
 
-  I alias paths like `.ssh' to make it convenient to type:
+  Complex profiles are hard coded & simple ones are generated. Complex
+  profiles include profiles that have multiple files or are a mix or
+  files & directories. Simple profiles are profiles with just single
+  directory.
 
-  ┌────
-  │ # Aliases for inconvenient paths.
-  │ $dispatch{ssh} = $dispatch{".ssh"};
-  │ $dispatch{pass} = $dispatch{".password-store"};
-  └────
+  You can run `help' to see all the profiles along with the paths.
 
 
 1.2 Options
diff --git a/leo.pl b/leo.pl
index 1222963..cd6a297 100755
--- a/leo.pl
+++ b/leo.pl
@@ -11,7 +11,7 @@ use Getopt::Long qw/ GetOptions /;
 my %options = ();
 GetOptions(
     \%options,
-    qw{ verbose encrypt sign delete }
+    qw{ verbose encrypt sign delete help }
 ) or die "Error in command line arguments\n";
 
 $options{encrypt} = $ENV{LEO_ENCRYPT};
@@ -45,7 +45,7 @@ $profile{ssh} = $profile{".ssh"};
 $profile{pass} = $profile{".password-store"};
 $profile{mozilla} = $profile{".mozilla"};
 
-HelpMessage() and exit 0 if scalar @ARGV == 0;
+HelpMessage() and exit 0 if scalar @ARGV == 0 or $options{help};
 foreach my $arg ( @ARGV ) {
     $prof = $arg; # Set $prof.
     if ( $profile{ $arg } ) {
@@ -129,7 +129,8 @@ Options:
         Sign files with $gpg_fingerprint
     --delete
         Delete the archive after running gpg2
-    --verbose};
+    --verbose
+    --help};
 }
 
 
/a> 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478