From 25980a90fec600a9c4fd60af0d4ed243b011d806 Mon Sep 17 00:00:00 2001 From: gaurav Date: Fri, 27 May 2016 19:05:35 +0530 Subject: 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. --- lib/WWW/Pocket/Script.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3