aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ManaTools/Shared/CommandLine.pm
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-11-17 13:38:15 +0100
committerAngelo Naselli <anaselli@linux.it>2015-11-17 13:38:15 +0100
commit8cf923f9d6f1cd311154aadafd4e46338d8d51f2 (patch)
tree97aa1a0a9a1d6ae2038c3ed083faa12f063dfbb7 /lib/ManaTools/Shared/CommandLine.pm
parentfc7e31c3739a7a98a6c5970d9a323e38ba05614e (diff)
downloadmanatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar
manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.gz
manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.bz2
manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.xz
manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.zip
Added ComandLine module
Diffstat (limited to 'lib/ManaTools/Shared/CommandLine.pm')
-rw-r--r--lib/ManaTools/Shared/CommandLine.pm91
1 files changed, 91 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/CommandLine.pm b/lib/ManaTools/Shared/CommandLine.pm
new file mode 100644
index 00000000..9650e217
--- /dev/null
+++ b/lib/ManaTools/Shared/CommandLine.pm
@@ -0,0 +1,91 @@
+# vim: set et ts=4 sw=4:
+package ManaTools::Shared::CommandLine;
+#============================================================= -*-perl-*-
+
+=head1 NAME
+
+ ManaTools::Shared::CommandLine - A common command line management
+
+=head1 SYNOPSIS
+
+ use ManaTools::Shared::CommandLine;
+
+ my $cl = ManaTools::Shared::CommandLine->new();
+ $cl->new_with_options();
+
+=head1 DESCRIPTION
+
+ This class extends MooseX::Getopt adding the option --locales-dir and its
+ documentation. This option is usually caught by modules to look for translation
+ files into the given directory instead of the default one, and it is useful for
+ translators and translation testers.
+
+=head1 SUPPORT
+
+ You can find documentation for this module with the perldoc command:
+ perldoc ManaTools::Shared::CommandLine
+
+=head1 SEE ALSO
+
+ MooseX::Getopt
+
+=head1 AUTHOR
+
+ Angelo Naselli <angelo.naselli@softeco.it>
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2015, Angelo Naselli.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2, as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+=head1 SUBROUTINES/METHODS
+
+=cut
+use Moose;
+with qw/MooseX::Getopt/;
+use Getopt::Long qw(:config pass_through no_auto_version no_auto_help);
+
+use diagnostics;
+use utf8;
+
+use ManaTools::Shared::Locales;
+
+
+my $loc = ManaTools::Shared::Locales->new();
+
+has 'locales_dir' => (
+ traits => [ 'Getopt' ],
+ isa => 'Str',
+ is => 'ro',
+ cmd_flag => 'locales-dir',
+ documentation => $loc->N('<dir> optional directory contanining localization strings (developer only)',)
+);
+
+# Overriding help_flag from MooseX::Getopt::GLD so we can translate the usage string message
+# captures the options: --help --usage --? -? -h
+has help_flag => (
+ is => 'ro', isa => 'Bool',
+ traits => ['Getopt'],
+ cmd_flag => 'help',
+ cmd_aliases => [ qw(usage ? h) ],
+ documentation => $loc->N("Prints this usage information."),
+);
+
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;
+