[Gambas-user] Args help , most other places is -?

Bruce Steers bsteers4 at gmail.com
Fri Jul 1 14:38:07 CEST 2022


Inline...

On Thu, 30 Jun 2022 at 13:21, Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Le 30/06/2022 à 02:21, Bruce Steers a écrit :
> >
> > Fair point. Now I'm thinking harder I can't think of any other reason
> > myself other than -?
> > Maybe I could make it check for -? With a property?
> Args.QuestionMarkIsHelp
>
> Just let the user handle both cases if he wants, and implement both
> options in the default help management.
>

Hows about a property Args.HelpShortName = "h"  and if you want to use -?
or the letter the word help begins with in your language or use -h for
something else then you can just change Args.HelpShortName


>
> >     Another point: I didn't notice that you added a 'Args.HelpText()'
> >     method
> >     with an optional argument. It's quite an ugly interface! Why whould
> you
> >     need the automatically generated text as a string instead of
> >     printing it?
> >
> >
> > To begin with the Args.HelpText() method did not have an option to print
> > it just returned the text for printing with 'Print Args HelpText()'
> > I guess I thought printing it would be most used so I added the option.
> > Clearly I am not as sane as you 🤪
> > I think it has uses. The arg descriptions could contain Subst() tokens
> > and be customised at runtime using the text.
>
> Sorry, but I don't see the need of that. Don't add unneeded complexity
> to an interface that must be kept as simple as possible. And, by the
> way, 'HelpText' is the name of a property. As a method, you should have
> named it something like 'GetHelpText()', and never let a method both
> returning something and/or print it!
>
> I prefer a 'PrintHelp()' method, that would be used only when the user
> handles the '-h' (or '-?') option itself.
>
> But now that it's in a stable version, we can't remove it. :-(
>

aah, dang, sorry about that.
I cannot imagine many if any have used it yet.
Perhaps a change could slip by unnoticed? (i'll take full
responsibility/blame)
I think it's best as a property returning the text for you to print and not
an auto-printing method as it opens the possibility of modifying the text
first


>
> > Am adding a boolean property to the class due to what other Bruce said
> > called Args.ExpandShortNames. if true It stops an arg like -ab being
> > seen as -a and -b and sees it as -ab.
>
> I don't think that should be optional. I prefer that you remove the
> property and always handle option combination. Long options always begin
> with two minus signs.
>

Sadly my way of auto-checking was wrong and looks like it will take some
coding to handle combinations due to the way Args are processed, all
application Args being read in at .Begin() then processed with each .Has()
, .Get() call makes it far more complicated and could require a bit of a
re-write in how the args are processed.

Adding a switch to either use short name grouping or not works really
simply.

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220701/bdf59451/attachment.htm>


More information about the User mailing list