about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-11-11 15:15:46 +0530
committerAndinus <andinus@nand.sh>2020-11-11 15:15:46 +0530
commit546488b794abbc187fd070ccf54dd11842dec071 (patch)
tree8a9e195faf78cb2fedf02ca1e533dee19c9f64fb
parente1ceacf5a2ad5b389377a70190b1a979f59e19b0 (diff)
downloadleo-546488b794abbc187fd070ccf54dd11842dec071.tar.gz
Add option to print version, check for variable before splitting v0.3.3
-rwxr-xr-xleo.pl14
1 files changed, 12 insertions, 2 deletions
diff --git a/leo.pl b/leo.pl
index 92322db..1a12070 100755
--- a/leo.pl
+++ b/leo.pl
@@ -9,6 +9,8 @@ use Path::Tiny;
 use Config::Tiny;
 use Getopt::Long qw/ GetOptions /;
 
+my $version = "leo v0.3.3";
+
 # Options.
 
 my %options = (
@@ -20,9 +22,12 @@ my %options = (
 
 GetOptions(
     \%options,
-    qw{ verbose encrypt sign signify gzip help }
+    qw{ verbose encrypt sign signify gzip help version }
 ) or die "Error in command line arguments\n";
 
+# Print version.
+print $version, "\n" and exit 0 if $options{version};
+
 # Configuration.
 
 my $config_file = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config";
@@ -71,7 +76,11 @@ my $backup_dir = $options{backup_dir} || "/tmp/backups";
 path($backup_dir)->mkpath; # Create backup directory.
 
 my $gpg_fingerprint = $options{gpg_fingerprint} || "`nil'";
-my @gpg_recipients = split / /, $options{gpg_recipients};
+
+my @gpg_recipients;
+@gpg_recipients = split / /, $options{gpg_recipients}
+    if $options{gpg_recipients};
+
 my $gpg_bin = $options{gpg_bin} || "gpg";
 
 # Print help.
@@ -243,6 +252,7 @@ Profile:};
     print qq{
         Compress with gzip(1)
 
+    --version [$version]
     --verbose
     --help
 };