From 80a47a62a1600dc3449f2d876c913f496f8d3907 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 8 Jun 2010 11:26:24 +0200 Subject: update name of api methods; fetch doc from method --- lib/Net/HTTP/Console/Dispatcher/Help.pm | 57 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) (limited to 'lib/Net/HTTP/Console/Dispatcher/Help.pm') diff --git a/lib/Net/HTTP/Console/Dispatcher/Help.pm b/lib/Net/HTTP/Console/Dispatcher/Help.pm index d38b186..7055b2b 100644 --- a/lib/Net/HTTP/Console/Dispatcher/Help.pm +++ b/lib/Net/HTTP/Console/Dispatcher/Help.pm @@ -5,16 +5,21 @@ with qw/Net::HTTP::Console::Dispatcher/; sub dispatch { my ($self, $input) = @_; - $input =~ /^help\s(.*)?/; - my $cmd = $1; - if ($cmd) { - }else{ - print <_get_help_for_command($cmd_name); + } + elsif ($cmd eq 'command') { + $self->_list_commands(); + } + } + else { + $self->_display_help(); } + 1; } sub pattern { @@ -22,4 +27,40 @@ sub pattern { $input =~ /^help/ ? return $input : return 0; } +sub _display_help { + print <application->api_object->meta->get_all_net_api_methods(); + + if (!@methods) { + print "no method available\n"; + return; + } + + print "available commands:\n"; + map { print "- " . $_ . "\n" } @methods; +} + +sub _get_help_for_command { + my ($self, $cmd_name) = @_; + + my $method = + $self->application->api_object->meta->find_net_api_method_by_name( + $cmd_name); + + if (!$method) { + print "unknown method " . $cmd_name . "\n"; + return; + } + + print $method->documentation; +} + 1; -- cgit 1.4.1