From f5d5e7f98d1f1f52a19304d2b868d30c7a46e267 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Wed, 14 Feb 2018 09:05:23 -0700 Subject: [PATCH] improve error message for no keyfile or secret --- lib/App/GroupSecret.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/App/GroupSecret.pm b/lib/App/GroupSecret.pm index 98f3212..ce85e9d 100644 --- a/lib/App/GroupSecret.pm +++ b/lib/App/GroupSecret.pm @@ -114,7 +114,6 @@ Get the path to the keyfile. sub filepath { shift->{filepath} ||= $ENV{GROUPSECRET_KEYFILE} || 'groupsecret.yml'; - } =method file @@ -152,7 +151,11 @@ sub _action_print_secret { ) or pod2usage(2); my $file = $self->file; - die "No secret in file -- use the \`set-secret' command to set one.\n" if !$file->secret; + my $filepath = $file->filepath; + die "No keyfile '$filepath' exists -- use the \`add-key' command to create one.\n" + unless -e $filepath && !-d $filepath; + die "No secret in keyfile '$filepath' exists -- use the \`set-secret' command to set one.\n" + if !$file->secret; if ($decrypt) { my $private_key = $self->private_key; -- 2.43.0