commit 7cbb7faab069d95a8822fbfde5dded1f38d15c1f
parent 1299a04fa3eef185926a04ce7b434c56d504c515
Author: lumidify <nobody@lumidify.org>
Date: Mon, 23 Mar 2020 18:16:55 +0100
Start writing perldoc
Diffstat:
M | lumia.pl | | | 110 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
1 file changed, 107 insertions(+), 3 deletions(-)
diff --git a/lumia.pl b/lumia.pl
@@ -17,6 +17,7 @@ use File::Spec::Functions qw(catfile abs2rel);
use File::Basename qw(basename dirname);
use File::Path qw(remove_tree);
use String::ShellQuote;
+use Pod::Usage;
# the file used to store checksums for files
my $CKSUM_FILE = ".lumidify_archive_cksums";
@@ -856,9 +857,8 @@ sub update {
}
}
-if ($#ARGV < 0) {
- die("USAGE: test.pl {init|check|clean|checknew|addnew|checkold|rmold|extract|cp|mv|rm|mkdir|update}\n");
-}
+pod2usage(1) if $#ARGV < 0;
+
if ($ARGV[0] eq "mv") {
if ($#ARGV < 2) {
die "mv requires at least two arguments\n";
@@ -941,4 +941,108 @@ if ($ARGV[0] eq "mv") {
die "update requires at least one argument\n";
}
update @ARGV[1..$#ARGV];
+} elsif ($ARGV[0] eq "help") {
+ pod2usage(-exitval => 0, -verbose => 2);
}
+
+__END__
+
+=head1 SYNOPSIS
+
+B<lumia.pl> command arguments
+
+=head1 COMMANDS
+
+=over 8
+
+=item B<addnew> [directory]
+
+Walks through B<directory>, adding all new files to the checksum database.
+B<directory> defaults to the current directory.
+
+=item B<checknew> [directory]
+
+Walks through B<directory>, printing all files that aren't part of the checksum
+database. B<directory> defaults to the current directory.
+
+=item B<checkold> [directory]
+
+Prints all files in the checksum database that do not exist on the filesystem anymore.
+B<directory> defaults to the current directory.
+
+=item B<rmold> [directory]
+
+Deletes all files found by B<checkold>. B<directory> defaults to the current directory.
+
+=item B<check> [directory]
+
+Recurses through B<directory>, checking all checksums in the database against the new
+checksums of the files on the filesystem. B<directory> defaults to the current directory.
+
+=item B<clean> [directory]
+
+Removes all lumia special files used to store the checksum database from B<directory>
+recursively. B<directory> defaults to the current directory.
+
+=item B<extract> [source] destination
+
+Recreates the entire directory structure from B<source> in B<destination>, but only
+copies the special files used to store the checksum database. B<source> defaults to
+the current directory.
+
+=item B<mkdir> directory ...
+
+Creates the given directories, initializing them with empty checksum database files.
+
+=item B<update> file ...
+
+Recalculates the checksums for the given files and replaces them in the database.
+
+Note: Directories are ignored.
+
+=item B<rm> file ...
+
+Removes the given files and directories from the filesystem and checksum database.
+
+=item B<cp> source target
+
+=item B<cp> source ... directory
+
+Copies the given source files, updating the checksum database in the process.
+
+If the last argument is a file, there must be only one source argument, also a file,
+which is then copied to the target.
+
+If the last argument is a directory, all source arguments are copied into it.
+
+=item B<mv> source target
+
+=item B<mv> source ... directory
+
+Moves the given source files, updating the checksum database in the process.
+
+If the last argument is a file or does not exist, there must be only one source
+argument, which is renamed to the target name.
+
+If the last argument is an existing directory, all source arguments are moved
+into it.
+
+=back
+
+=head1 LICENSE
+
+Copyright (c) 2019, 2020 lumidify <nobody[at]lumidify.org>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+=cut