[carton] 95/472: Implemented alias like git
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:36 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to branch master
in repository carton.
commit 5d7cae0a5caeeb58769245c962df6cc3f1ecf79a
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date: Fri Jul 1 14:49:56 2011 -0700
Implemented alias like git
---
Makefile.PL | 1 +
lib/Carton/CLI.pm | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/Makefile.PL b/Makefile.PL
index 4279032..79a30a8 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -15,6 +15,7 @@ requires 'Try::Tiny', 0.09;
requires 'parent', 0.223;
requires 'Config::GitLike', 1.05;
requires 'Mouse', 0.93;
+requires 'Text::ParseWords', 3.10;
install_script 'bin/carton';
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index eb9fcad..8eca724 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -72,6 +72,12 @@ sub run {
push @commands, @ARGV;
my $cmd = shift @commands || 'usage';
+
+ if (my @alias = $self->find_alias($cmd)) {
+ $cmd = shift @alias;
+ unshift @commands, @alias;
+ }
+
my $call = $self->can("cmd_$cmd");
if ($call) {
@@ -86,6 +92,16 @@ sub run {
}
}
+sub find_alias {
+ my($self, $cmd) = @_;
+
+ my $alias = $self->config->get(key => "alias.$cmd")
+ or return;
+
+ require Text::ParseWords;
+ return Text::ParseWords::shellwords($alias);
+}
+
sub commands {
my $self = shift;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git
More information about the Pkg-perl-cvs-commits
mailing list