[Bps-public-commit] Prophet branch, master, updated. c7b5a54cfc7f59cb4a159e2fd2cf2c5a51e45e3c

spang at bestpractical.com spang at bestpractical.com
Mon Aug 17 07:39:40 EDT 2009


The branch, master has been updated
       via  c7b5a54cfc7f59cb4a159e2fd2cf2c5a51e45e3c (commit)
      from  a238ab408856aaf818d38315faa83bc88d6a8898 (commit)

Summary of changes:
 lib/Prophet/CLI.pm                  |   18 ++++++++++++++++++
 lib/Prophet/CLI/Command.pm          |   20 +-------------------
 lib/Prophet/CLI/Command/Aliases.pm  |    6 +++---
 lib/Prophet/CLI/Command/Clone.pm    |    2 +-
 lib/Prophet/CLI/Command/Config.pm   |    6 +++---
 lib/Prophet/CLI/Command/Export.pm   |    2 +-
 lib/Prophet/CLI/Command/Info.pm     |    2 +-
 lib/Prophet/CLI/Command/Init.pm     |    2 +-
 lib/Prophet/CLI/Command/Log.pm      |    2 +-
 lib/Prophet/CLI/Command/Merge.pm    |    2 +-
 lib/Prophet/CLI/Command/Mirror.pm   |    2 +-
 lib/Prophet/CLI/Command/Publish.pm  |    2 +-
 lib/Prophet/CLI/Command/Pull.pm     |    2 +-
 lib/Prophet/CLI/Command/Push.pm     |    2 +-
 lib/Prophet/CLI/Command/Settings.pm |    2 +-
 lib/Prophet/CLI/Command/Shell.pm    |    2 +-
 16 files changed, 37 insertions(+), 37 deletions(-)

- Log -----------------------------------------------------------------
commit c7b5a54cfc7f59cb4a159e2fd2cf2c5a51e45e3c
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 17 12:29:33 2009 +0100

    Move get_cmd_name to Prophet::CLI and rename to get_script_name
    
    Sometimes we want to get the name of the running script when not
    in a command--e.g., in the dispatcher. And calling it
    get_cmd_name is confusingly ambiguous -- do we mean the name of
    the script that has been run, or the name of the Prophet command?

diff --git a/lib/Prophet/CLI.pm b/lib/Prophet/CLI.pm
index d04085b..26191da 100644
--- a/lib/Prophet/CLI.pm
+++ b/lib/Prophet/CLI.pm
@@ -186,6 +186,24 @@ sub end_pager {
     $ORIGINAL_STDOUT = undef;
 }
 
+=head2 get_script_name
+
+Return the name of the script that was run. This is the empty string
+if we're in a shell, otherwise the script name concatenated with
+a space character. This is so you can just use this for e.g.
+printing usage messages or help docs that might be run from either
+a shell or the command line.
+
+=cut
+
+sub get_script_name {
+    my $self = shift;
+    return '' if $self->interactive_shell;
+    require File::Spec;
+    my ($cmd) = ( File::Spec->splitpath($0) )[2];
+    return $cmd . ' ';
+}
+
 END {
    *STDOUT = $ORIGINAL_STDOUT if $ORIGINAL_STDOUT;
 }
diff --git a/lib/Prophet/CLI/Command.pm b/lib/Prophet/CLI/Command.pm
index 40a6f9f..a84d5b2 100644
--- a/lib/Prophet/CLI/Command.pm
+++ b/lib/Prophet/CLI/Command.pm
@@ -306,24 +306,6 @@ sub print_usage {
     die $args{usage_method}();
 }
 
-=head2 get_cmd_name
-
-Return the name of the script that was run. This is the empty string
-if we're in a shell, otherwise the script name concatenated with
-a space character. This is so you can just use this for e.g.
-printing usage messages or help docs that might be run from either
-a shell or the command line.
-
-=cut
-
-sub get_cmd_name {
-    my $self = shift;
-    return '' if $self->cli->interactive_shell;
-    require File::Spec;
-    my ($cmd) = ( File::Spec->splitpath($0) )[2];
-    return $cmd . ' ';
-}
-
 =head2 get_cmd_and_subcmd_names [no_type => 1]
 
 Gets the name of the script that was run and the primary commands that were
@@ -337,7 +319,7 @@ sub get_cmd_and_subcmd_names {
     my $self = shift;
     my %args = @_;
 
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
     my @primary_commands = @{ $self->context->primary_commands };
 
     # if primary commands was only length 1, the type was not specified
diff --git a/lib/Prophet/CLI/Command/Aliases.pm b/lib/Prophet/CLI/Command/Aliases.pm
index bfb1c06..b07859d 100644
--- a/lib/Prophet/CLI/Command/Aliases.pm
+++ b/lib/Prophet/CLI/Command/Aliases.pm
@@ -8,7 +8,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(), s => 'show' };
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}aliases [show]
@@ -161,7 +161,7 @@ sub process_template {
 # Aliases
 override delete_usage_msg => sub {
     my $self = shift;
-    my $app_cmd = $self->get_cmd_name;
+    my $app_cmd = $self->cli->get_script_name;
     my $cmd = shift;
 
     qq{usage: ${app_cmd}${cmd} "alias text"\n};
@@ -169,7 +169,7 @@ override delete_usage_msg => sub {
 
 override add_usage_msg => sub {
     my $self = shift;
-    my $app_cmd = $self->get_cmd_name;
+    my $app_cmd = $self->cli->get_script_name;
     my ($cmd, $subcmd) = @_;
 
     qq{usage: ${app_cmd}$cmd $subcmd "alias text" "cmd to translate to"\n};
diff --git a/lib/Prophet/CLI/Command/Clone.pm b/lib/Prophet/CLI/Command/Clone.pm
index b6fe84a..0b5be3a 100644
--- a/lib/Prophet/CLI/Command/Clone.pm
+++ b/lib/Prophet/CLI/Command/Clone.pm
@@ -4,7 +4,7 @@ extends 'Prophet::CLI::Command::Merge';
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}clone --from <url>
diff --git a/lib/Prophet/CLI/Command/Config.pm b/lib/Prophet/CLI/Command/Config.pm
index 7b56ffd..4c89e0d 100644
--- a/lib/Prophet/CLI/Command/Config.pm
+++ b/lib/Prophet/CLI/Command/Config.pm
@@ -24,7 +24,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  a => 'add', d => 'dele
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}config [show]
@@ -339,7 +339,7 @@ sub _setup_new_syntax_add_subcmd {
 
 sub delete_usage_msg {
     my $self = shift;
-    my $app_cmd = $self->get_cmd_name;
+    my $app_cmd = $self->cli->get_script_name;
     my $cmd = shift;
 
     qq{usage: ${app_cmd}${cmd} section.subsection.var\n};
@@ -347,7 +347,7 @@ sub delete_usage_msg {
 
 sub add_usage_msg {
     my $self = shift;
-    my $app_cmd = $self->get_cmd_name;
+    my $app_cmd = $self->cli->get_script_name;
     my ($cmd, $subcmd) = @_;
 
     qq{usage: ${app_cmd}${cmd} ${subcmd} section.subsection.var ["key value"]\n};
diff --git a/lib/Prophet/CLI/Command/Export.pm b/lib/Prophet/CLI/Command/Export.pm
index d24b11f..3058c2b 100644
--- a/lib/Prophet/CLI/Command/Export.pm
+++ b/lib/Prophet/CLI/Command/Export.pm
@@ -4,7 +4,7 @@ extends 'Prophet::CLI::Command';
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}export --path <path> [--format feed]
diff --git a/lib/Prophet/CLI/Command/Info.pm b/lib/Prophet/CLI/Command/Info.pm
index 18ff766..4d537f5 100644
--- a/lib/Prophet/CLI/Command/Info.pm
+++ b/lib/Prophet/CLI/Command/Info.pm
@@ -6,7 +6,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  l => 'local' };
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}info
diff --git a/lib/Prophet/CLI/Command/Init.pm b/lib/Prophet/CLI/Command/Init.pm
index 32b7229..30c3170 100644
--- a/lib/Prophet/CLI/Command/Init.pm
+++ b/lib/Prophet/CLI/Command/Init.pm
@@ -4,7 +4,7 @@ extends 'Prophet::CLI::Command';
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
     my $env_var = uc $cmd . '_REPO';
     $env_var =~ s/ //;
 
diff --git a/lib/Prophet/CLI/Command/Log.pm b/lib/Prophet/CLI/Command/Log.pm
index f2c949a..2600351 100644
--- a/lib/Prophet/CLI/Command/Log.pm
+++ b/lib/Prophet/CLI/Command/Log.pm
@@ -4,7 +4,7 @@ extends 'Prophet::CLI::Command';
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}log --all              Show all entries
diff --git a/lib/Prophet/CLI/Command/Merge.pm b/lib/Prophet/CLI/Command/Merge.pm
index 5a0af36..776b6d8 100644
--- a/lib/Prophet/CLI/Command/Merge.pm
+++ b/lib/Prophet/CLI/Command/Merge.pm
@@ -13,7 +13,7 @@ sub ARG_TRANSLATIONS {
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}merge --from <replica> --to <replica> [options]
diff --git a/lib/Prophet/CLI/Command/Mirror.pm b/lib/Prophet/CLI/Command/Mirror.pm
index d7ad37f..c6402c7 100644
--- a/lib/Prophet/CLI/Command/Mirror.pm
+++ b/lib/Prophet/CLI/Command/Mirror.pm
@@ -12,7 +12,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  f => 'force' };
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}mirror --from <url>
diff --git a/lib/Prophet/CLI/Command/Publish.pm b/lib/Prophet/CLI/Command/Publish.pm
index 84d7181..c04676b 100644
--- a/lib/Prophet/CLI/Command/Publish.pm
+++ b/lib/Prophet/CLI/Command/Publish.pm
@@ -9,7 +9,7 @@ use File::Spec;
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}publish --to <location|name> [--html] [--replica]
diff --git a/lib/Prophet/CLI/Command/Pull.pm b/lib/Prophet/CLI/Command/Pull.pm
index 6940804..8c2a0bd 100644
--- a/lib/Prophet/CLI/Command/Pull.pm
+++ b/lib/Prophet/CLI/Command/Pull.pm
@@ -6,7 +6,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  l => 'local' };
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}pull --from <url|name>
diff --git a/lib/Prophet/CLI/Command/Push.pm b/lib/Prophet/CLI/Command/Push.pm
index 775ccd3..d4f6e9e 100644
--- a/lib/Prophet/CLI/Command/Push.pm
+++ b/lib/Prophet/CLI/Command/Push.pm
@@ -4,7 +4,7 @@ extends 'Prophet::CLI::Command::Merge';
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}push --to <url|name> [--force]
diff --git a/lib/Prophet/CLI/Command/Settings.pm b/lib/Prophet/CLI/Command/Settings.pm
index c4edc3d..47971ad 100644
--- a/lib/Prophet/CLI/Command/Settings.pm
+++ b/lib/Prophet/CLI/Command/Settings.pm
@@ -10,7 +10,7 @@ sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  s => 'show' };
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}settings [show]
diff --git a/lib/Prophet/CLI/Command/Shell.pm b/lib/Prophet/CLI/Command/Shell.pm
index a1ced58..b4041ff 100644
--- a/lib/Prophet/CLI/Command/Shell.pm
+++ b/lib/Prophet/CLI/Command/Shell.pm
@@ -30,7 +30,7 @@ has term => (
 
 sub usage_msg {
     my $self = shift;
-    my $cmd = $self->get_cmd_name;
+    my $cmd = $self->cli->get_script_name;
 
     return <<"END_USAGE";
 usage: ${cmd}\[shell]

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list