From f6235f3365decadd339ad654fc000ed5852c7b3b Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sun, 3 May 2015 23:18:41 +0200 Subject: Added help_requested (checked from command line) --- lib/ManaTools/Shared.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib') 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 -- cgit v1.2.1