From: benoit.person@ensimag.fr
To: git@vger.kernel.org
Cc: Celestin Matte <celestin.matte@ensimag.fr>,
Jeff King <peff@peff.net>,
Matthieu Moy <matthieu.moy@grenoble-inp.fr>,
Benoit Person <benoit.person@ensimag.fr>
Subject: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script
Date: Thu, 13 Jun 2013 12:07:18 +0200 [thread overview]
Message-ID: <1371118039-18925-4-git-send-email-benoit.person@ensimag.fr> (raw)
In-Reply-To: <1371118039-18925-1-git-send-email-benoit.person@ensimag.fr>
From: Benoit Person <benoit.person@ensimag.fr>
This script will be used for all tools and command related to a mediawiki
remote. In this commit we introduce the tool, the way it parses argument
and subcommands and an example of subcommand: "help". It also updates
the Makefile so that the new tool is installed properly.
Signed-off-by: Benoit Person <benoit.person@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
---
contrib/mw-to-git/Makefile | 7 ++++---
contrib/mw-to-git/git-mw.perl | 46 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 3 deletions(-)
create mode 100644 contrib/mw-to-git/git-mw.perl
diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
index fe30e7f..c0633b1 100644
--- a/contrib/mw-to-git/Makefile
+++ b/contrib/mw-to-git/Makefile
@@ -6,6 +6,7 @@
GIT_MEDIAWIKI_PM=GitMediawiki.pm
SCRIPT_PERL=git-remote-mediawiki.perl
+SCRIPT_PERL+=git-mw.perl
GIT_ROOT_DIR=../..
HERE=contrib/mw-to-git/
@@ -19,14 +20,14 @@ install_pm:
cp $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)
build:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \
+ $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
build-perl-script
install: install_pm
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \
+ $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
install-perl-script
clean:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \
+ $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
clean-perl-script
rm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
\ No newline at end of file
diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl
new file mode 100644
index 0000000..a2f0aa1
--- /dev/null
+++ b/contrib/mw-to-git/git-mw.perl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2013
+# Benoit Person <benoit.person@ensimag.imag.fr>
+# Celestin Matte <celestin.matte@ensimag.imag.fr>
+# License: GPL v2 or later
+
+# Set of tools for git repo with a mediawiki remote.
+# Documentation & bugtracker: https://github.com/moy/Git-Mediawiki/
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my %commands = (
+ 'help' =>
+ [\&help, {}, \&help]
+);
+
+# Search for sub-command
+my $cmd = $commands{'help'};
+for (my $i = 0; $i < @ARGV; $i++) {
+ if (defined $commands{$ARGV[$i]}) {
+ $cmd = $commands{$ARGV[$i]};
+ splice @ARGV, $i, 1;
+ last;
+ }
+};
+GetOptions( %{$cmd->[1]},
+ 'help|h' => \&{$cmd->[2]});
+
+# Launch command
+&{$cmd->[0]};
+
+############################## Help Functions ##################################
+
+sub help {
+ print <<'END';
+usage: git mw <command> <args>
+
+git mw commands are:
+ Help Display help information about git mw
+END
+ exit;
+}
\ No newline at end of file
--
1.8.3.GIT
next prev parent reply other threads:[~2013-06-13 10:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-13 10:07 [PATCH/RFC V2 0/4] git-remote-mediawiki: new tool to preview local changes without pushing benoit.person
2013-06-13 10:07 ` [PATCH/RFC 1/4] git-mw: Introduction of GitMediawiki.pm benoit.person
2013-06-13 11:44 ` Matthieu Moy
2013-06-13 10:07 ` [PATCH/RFC 2/4] git-mw: Moving some functions from git-remote-mediawiki.perl to GitMediawiki.pm benoit.person
2013-06-13 10:07 ` benoit.person [this message]
2013-06-13 13:01 ` [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script Matthieu Moy
2013-06-15 13:22 ` Benoît Person
2013-06-16 19:59 ` Matthieu Moy
2013-06-24 14:26 ` Matthieu Moy
2013-06-24 16:38 ` Junio C Hamano
2013-06-24 16:56 ` Matthieu Moy
2013-06-24 17:00 ` Jeff King
2013-06-24 17:05 ` Benoit Person
2013-06-24 17:23 ` Junio C Hamano
2013-06-13 10:07 ` [PATCH/RFC 4/4] git-mw: Adding preview tool in git-mw.perl benoit.person
2013-06-13 12:13 ` Matthieu Moy
2013-06-13 11:23 ` [PATCH/RFC V2 0/4] git-remote-mediawiki: new tool to preview local changes without pushing Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371118039-18925-4-git-send-email-benoit.person@ensimag.fr \
--to=benoit.person@ensimag.fr \
--cc=celestin.matte@ensimag.fr \
--cc=git@vger.kernel.org \
--cc=matthieu.moy@grenoble-inp.fr \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).