diff options
author | Angelo Naselli <anaselli@linux.it> | 2015-11-17 13:38:15 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2015-11-17 13:38:15 +0100 |
commit | 8cf923f9d6f1cd311154aadafd4e46338d8d51f2 (patch) | |
tree | 97aa1a0a9a1d6ae2038c3ed083faa12f063dfbb7 | |
parent | fc7e31c3739a7a98a6c5970d9a323e38ba05614e (diff) | |
download | manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.gz manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.bz2 manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.tar.xz manatools-8cf923f9d6f1cd311154aadafd4e46338d8d51f2.zip |
Added ComandLine module
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | lib/ManaTools/Shared/CommandLine.pm | 91 | ||||
-rw-r--r-- | lib/ManaTools/Shared/GUI/CommandLine.pm | 101 |
3 files changed, 193 insertions, 0 deletions
@@ -1,3 +1,4 @@ + - Added CommandLine module to manage common CL options - Added event_timeout rw attribute to GUI::Dialog to allow manage $yui::YEvent::TimeoutEvent - Fixed ExtTab to be both EventRole and Event, which means 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; + diff --git a/lib/ManaTools/Shared/GUI/CommandLine.pm b/lib/ManaTools/Shared/GUI/CommandLine.pm new file mode 100644 index 00000000..65efcfdd --- /dev/null +++ b/lib/ManaTools/Shared/GUI/CommandLine.pm @@ -0,0 +1,101 @@ +# vim: set et ts=4 sw=4: +package ManaTools::Shared::GUI::CommandLine; +#============================================================= -*-perl-*- + +=head1 NAME + + Manatools::Shared::GUI::CommandLine - Shared CommandLine extension with some yui parameters explanation + +=head1 SYNOPSIS + + use ManaTools::Shared::GUI::CommandLine; + + my $cl = ManaTools::Shared::GUI::CommandLine->new_with_options(); + $cl->usage(); + + # to extend it + use Moose; + extends 'ManaTools::Shared::GUI::CommandLine'; + use ManaTools::Shared::Locales; + + my $loc = ManaTools::Shared::Locales->new(); + + has 'new_option' => ( + traits => [ 'Getopt' ], + is => 'ro', + documentation => $loc->N('we have a new option to manage here') + ); + + +=head1 DESCRIPTION + + This class extends ManaTools::Shared::CommandLine adding the documentation for option such as + --qt, --gtk and --ncurses, options that are common to every Manatools::Module module, since they + use yui module. + + +=head1 SUPPORT + + You can find documentation for this module with the perldoc command: + perldoc Manatools::Shared::GUI::CommandLine + +=head1 SEE ALSO + + Manatools::Shared::CommandLine, MooseX::GetOpt + +=head1 AUTHOR + +Angelo Naselli <anaselli@linux.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 FUNCTIONS + +=cut + +use Moose; +extends 'ManaTools::Shared::CommandLine'; + +use ManaTools::Shared::Locales; + +my $loc = ManaTools::Shared::Locales->new(); + +has 'gtk' => ( + traits => [ 'Getopt' ], + is => 'ro', + documentation => $loc->N('start using yui gtk plugin implementation') +); + +has 'ncurses' => ( + traits => [ 'Getopt' ], + is => 'ro', + documentation => $loc->N('start using yui ncurses plugin implementation') +); + +has 'qt' => ( + traits => [ 'Getopt' ], + is => 'ro', + documentation => $loc->N('start using yui qt plugin implementation') +); + + +no Moose; +__PACKAGE__->meta->make_immutable; + +1; + |