Re: popt in Gnome2::Program

On Wed, 15 Sep 2004, Torsten Schoenfeld wrote:

On Mon, 2004-09-13 at 22:40, Peter Oliver wrote:

So, is there neat solution to this?  The best I've come up with is to put

     if ( grep { s/^-h$/--help/; m/^-(-help|\?)$/ } @ARGV ) {
         system $0, '--podhelp';

Couldn't you just print your help stuff here and call
Gnome2::Program->init nevertheless?  That would come quite close to what
the popt table stuff does: the application options are printed first,
followed by the library options.

That's what I'm trying to do.  I get my help with Pod::Usage, which
pulls the help text from the pod and then exits.  If there's a way to
prevent it from exiting, it isn't documented.

On Wed, 15 Sep 2004, Kevin C. Krinke wrote:

I've just come across this same issue and the resolution I came up with
was to simply allow --help to be taken care of by GNOME and instead use
-help for the application's usage. I've also documented that --help is
the Gtk2 usage info right along side the other help option indicators.

The catch, here, is that a user using --help will get the Gnome help and
not be told that the other help exists.  They'd probably figure it out
before too long, but it's not ideal.

On Wed, 15 Sep 2004, A. Pagaltzis wrote:

That does a lot of superfluous work. You could use something like

   @ARGV = map { /^-(?:h|-help)$/ ? "--podhelp" : $_ } @ARGV;

or even simply

   @ARGV = qw( --podhelp ) if grep /^-(?:h|-help)$/, @ARGV;

Of course, you could also just do

   pod2usage( -verbose => 1 ) if grep /^-(?:h|-help)$/, @ARGV;

I was aiming at getting both my help and the Gnome help for
completeness.  That said, there are screenfulls of Gnome options that
are probably never going to be used, so perhaps I'm better-off without
them.  I could just add a note to say standard Gnome options can also be

But none of these solutions will respect a -- terminator and will
not misrecognize a -h or --help passed as the value of an option.

Ahh.  I had forgotten all about "--".  More evidence that it's always
best to leave a job to a module when you can :-)

Thanks for the ideas.

Peter Oliver

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]