[Scons-users] bug with AddOption?

Daniel Moody dmoody256 at gmail.com
Thu Apr 28 17:19:17 EDT 2022


Do you have the nargs value set? What does your AddOption call look like?

In addition to the arguments and values supported by the optparse
*add_option* method, *AddOption* allows setting the *nargs* keyword value
to a string consisting of a question mark ('?') to indicate that the option
argument for that option string is optional. If the option string is
present on the command line but has no matching option argument, the value
of the *const* keyword argument is produced as the value of the option. If
the option string is omitted from the command line, the value of the
*default* keyword argument is produced, as usual; if there is no
*default* keyword
argument in the *AddOption* call, None is produced.

On Thu, Apr 28, 2022 at 4:04 PM Gabe Black <gabe.black at gmail.com> wrote:

> There seems to also be another problem here as well, although this one
> might be a usage error on my part. It looks like if you use the --linker
> option, you also have to use it in --linker=gold form, and can't use it as
> two arguments, ie --linker gold. I think both *should* work, so this might
> be another symptom of the first problem.
>
> Gabe
>
> On Thu, Apr 28, 2022 at 1:24 PM Gabe Black <gabe.black at gmail.com> wrote:
>
>> Hi, we have a legacy option, --gold-linker, which takes no parameter, and
>> a new option, --linker, which takes one option that may be "gold" or
>> several other values. We set up both options using AddOption and give them
>> both the same "dest", using the "store_const" action with const="gold" for
>> --gold-linker.
>>
>> This *mostly* works, except it looks like SCons conflates the format of
>> the two options, and *sort of* expects --gold-linker to have an option
>> value after it, even though it's a "store_const". I say *sort of* since it
>> doesn't look like --gold-linker actually consumes the value after it, it
>> will just complain if the value after it is another option.
>>
>> I think SCons is either not realizing that this type of flag should not
>> have a value after it, or is getting confused because these two differently
>> formatted options store to the same place. Minimally this behavior is
>> confusing.
>>
>> Gabe
>>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20220428/a99e322c/attachment.htm>


More information about the Scons-users mailing list