diff options
author | Angelo Naselli <anaselli@linux.it> | 2015-05-03 23:18:41 +0200 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2015-05-03 23:18:41 +0200 |
commit | f6235f3365decadd339ad654fc000ed5852c7b3b (patch) | |
tree | b4aa2521ff1da076ad064aa56c33c77a8638e5f1 | |
parent | fe4bc9a307f8a1c3c5e2193f0941e10290705651 (diff) | |
download | manatools-f6235f3365decadd339ad654fc000ed5852c7b3b.tar manatools-f6235f3365decadd339ad654fc000ed5852c7b3b.tar.gz manatools-f6235f3365decadd339ad654fc000ed5852c7b3b.tar.bz2 manatools-f6235f3365decadd339ad654fc000ed5852c7b3b.tar.xz manatools-f6235f3365decadd339ad654fc000ed5852c7b3b.zip |
Added help_requested (checked from command line)
-rw-r--r-- | lib/ManaTools/Shared.pm | 30 | ||||
-rw-r--r-- | t/08-Shared.t | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/ManaTools/Shared.pm b/lib/ManaTools/Shared.pm index feb2ebc7..20597890 100644 --- a/lib/ManaTools/Shared.pm +++ b/lib/ManaTools/Shared.pm @@ -46,6 +46,7 @@ This module collects all the routines shared between ManaTools and its modules. custom_locale_dir devel_mode command_line + help_requested =head1 SUPPORT @@ -102,6 +103,7 @@ our @EXPORT_OK = qw( custom_locale_dir devel_mode command_line + help_requested ); @@ -450,5 +452,33 @@ sub devel_mode() { return ($pos > 0) ? 1 : 0; } +#============================================================= + +=head2 help_requested + +=head3 OUTPUT + + boolean: 1 if "--help" or "-h" is passed to command line, 0 + otherwhise + +=head3 DESCRIPTION + + returns 1 if "--help" or "-h" is passed to command line, + modules should check this value to work accordingly + +=cut + +#============================================================= +sub help_requested() { + my $cmdline = ManaTools::Shared::command_line(); + my $pos = $cmdline->find("--help"); + return 1 if $pos > 0; + + $pos = $cmdline->find("--help"); + return 1 if $pos > 0; + + return 0; +} + 1; # End of ManaTools::Shared diff --git a/t/08-Shared.t b/t/08-Shared.t index 3489a4a0..a1c81ef3 100644 --- a/t/08-Shared.t +++ b/t/08-Shared.t @@ -10,6 +10,6 @@ BEGIN { ok ( ManaTools::Shared::command_line(), 'command_line'); is ( ManaTools::Shared::custom_locale_dir(), undef, 'custom_locale_dir'); is ( ManaTools::Shared::devel_mode(), 0, 'devel_mode'); - +is ( ManaTools::Shared::help_requested(), 0, 'help_requested'); done_testing; |