summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgaurav <gaurav@ggvaidya.com>2016-05-27 19:05:35 +0530
committergaurav <gaurav@ggvaidya.com>2016-05-27 19:05:35 +0530
commit25980a90fec600a9c4fd60af0d4ed243b011d806 (patch)
tree2dd5b2ea8aacd5031972598d025712cad8fd795f
parent73914c7b31b2cb1b6617544a9eda92cf8387e9f6 (diff)
downloadwww-pocket-25980a90fec600a9c4fd60af0d4ed243b011d806.tar.gz
www-pocket-25980a90fec600a9c4fd60af0d4ed243b011d806.zip
Added Pod::Usage to improve documentation.
Added a 'help' command to display synopsis and a fallback to display the full documentation if no commands are given.
-rw-r--r--lib/WWW/Pocket/Script.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/WWW/Pocket/Script.pm b/lib/WWW/Pocket/Script.pm
index daf237f..068ec3d 100644
--- a/lib/WWW/Pocket/Script.pm
+++ b/lib/WWW/Pocket/Script.pm
@@ -6,6 +6,7 @@ use JSON::PP;
use List::Util 'sum';
use Path::Class;
use URI;
+use Pod::Usage;
use WWW::Pocket;
@@ -55,7 +56,7 @@ sub run {
return $self->$method(@argv);
}
else {
- die "insert usage here";
+ pod2usage(-verbose => 2);
}
}
@@ -63,6 +64,7 @@ sub _method_is_command {
my $self = shift;
my ($name) = @_;
+ return unless $name;
return if $name eq 'run' || $name eq 'meta';
return if $name =~ /^_/;
my $method = $self->meta->find_method_by_name($name);
@@ -72,6 +74,12 @@ sub _method_is_command {
return 1;
}
+# Display help about this script.
+sub help {
+ my $self = shift;
+ pod2usage(-verbose => 1);
+}
+
sub authenticate {
my $self = shift;
$self->pocket;