[Bps-public-commit] r15015 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Mon Aug 11 16:43:25 EDT 2008


Author: sartak
Date: Mon Aug 11 16:43:25 2008
New Revision: 15015

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI.pm

Log:
 r69242 at onn:  sartak | 2008-08-11 16:42:48 -0400
 If the user specifies no arguments, open up a shell


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Mon Aug 11 16:43:25 2008
@@ -114,6 +114,9 @@
 set commands, arguments, and properties. Returns the class on success;
 dies on failure.
 
+This routine will use a C<CLI::Command::Shell> class if no arguments are
+specified.
+
 This routine will use a C<CLI::Command::NotFound> class as a last resort, so
 failure should occur rarely if ever.
 
@@ -130,6 +133,10 @@
     }
     my @commands = map { exists $CMD_MAP{$_} ? $CMD_MAP{$_} : $_ } @{ $tmp };
 
+    # allow overriding of default command. "./prophet" starts a prophet shell
+    @commands = $self->_default_command
+        if @commands == 0;
+
     my @possible_classes;
 
     my @to_try = @commands;
@@ -181,6 +188,15 @@
     return $class->new(%constructor_args);
 }
 
+=head2 _default_command
+
+Returns the "default" command for use when no arguments were specified on the
+command line. In Prophet, it's "shell" but your subclass can change that.
+
+=cut
+
+sub _default_command { "shell" }
+
 sub _try_to_load_cmd_class {
     my $self = shift;
     my $class = shift;



More information about the Bps-public-commit mailing list