From: <har...@us...> - 2009-02-14 16:59:50
|
Revision: 4720 http://net-policy.svn.sourceforge.net/net-policy/?rev=4720&view=rev Author: hardaker Date: 2009-02-14 16:59:46 +0000 (Sat, 14 Feb 2009) Log Message: ----------- allow for a no_gui option and new --nogui and --gui flags to user-control the option a bit more Modified Paths: -------------- trunk/net-policy/perl/Getopt_GUI/Long.pm Modified: trunk/net-policy/perl/Getopt_GUI/Long.pm =================================================================== --- trunk/net-policy/perl/Getopt_GUI/Long.pm 2009-01-06 22:27:27 UTC (rev 4719) +++ trunk/net-policy/perl/Getopt_GUI/Long.pm 2009-02-14 16:59:46 UTC (rev 4720) @@ -24,6 +24,7 @@ my %config = ( capture_output => 0, display_help => 0, + no_gui => 0, ); my @pass_to_qwizard_qs = qw(helpdesc helptext values labels default @@ -81,8 +82,20 @@ my %GUI_info; my $dohelp; + my $firstarg = ""; + + if ($main::ARGV[0] =~ /--*gui/ || $main::ARGV[0] =~ /--*no-gui/ || + $main::ARGV[0] =~ /--*nogui/) { + $firstarg = shift @main::ARGV; + $firstarg = '-' . $firstarg if ($firstarg =~ /^-[^-]/); + } + # If the user didn't specify any arguments, we display a GUI for them. - if ($#main::ARGV == -1 && eval "require QWizard") { + if ($firstarg ne '--nogui' && + $firstarg ne '--no-gui' && + (($#main::ARGV == -1 && !$config{'no_gui'}) || + $firstarg eq '--gui') && + eval "require QWizard") { require QWizard; import QWizard; @@ -627,6 +640,10 @@ 'Display help options -- long flags preferred'); _display_help_option_long('help-full','', 'Display all help options -- short and long'); + _display_help_option_long('gui','', + 'Display a help GUI'); + _display_help_option_long('no-gui','', + 'Do not display the default help GUI'); _display_help_option_long('version','', 'Display the version number') if ($GUI_info->{'VERSION'}); @@ -698,7 +715,7 @@ } sub GetInternalOptions { - return ('getopt-to-pod'); + return ('getopt-to-pod', 'gui', 'no-gui|nogui'); } # @@ -1145,6 +1162,18 @@ Shows all available option names for a given option +=item --gui + +If the default GUI is not showing up because no_gui has been +specified, a sure can still call the application with only the --gui +flag to make it appear. + +=item --no-gui + +If the no_gui option hasn't been set and the user doesn't want to see +the GUI then they can use the --no-gui flag as the only argument to +ensure it doesn't appear. + =back =item capture_output @@ -1153,6 +1182,12 @@ resulting STDOUT and STDERR results from the script and display the results in a window once the script has finished. +=item no_gui + +This option defaults to not presenting a GUI form for the user to fill +out B<unless> they specify --gui as the first and only argument on the +command line. + =back =head1 Using the QWizard object for other purposes @@ -1241,7 +1276,7 @@ =head1 COPYRIGHT and LICENSE -Copyright (c) 2006-2007, SPARTA, Inc. All rights reserved +Copyright (c) 2006-2009, SPARTA, Inc. All rights reserved Copyright (c) 2006-2007, Wes Hardaker. All rights reserved This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |