[Scons-users] Multiple AddOption with arguments

Bill Deegan bill at baddogconsulting.com
Thu Mar 14 13:38:48 EDT 2019


Keith,

The code in question should be in:
src/engine/SCons/Script/SConsOptions.py and Main.py

I've done a quick read through of the code and I can't see anything obvious
which is causing this.
So please go ahead and file a Github issue.

If you're willing to dig in and fix it with a PR that would be great.
I'm usually on SCons' IRC channel #scons on freenode if you'd like
help/pointers/etc in near real time.. ;)

-Bill

On Thu, Mar 14, 2019 at 10:02 AM Keith F Prussing <kprussing74 at gmail.com>
wrote:

> I am trying to debug an error I get when using multiple calls to
> AddOption.  Consider the following SConstruct
>
>     AddOption("--one")
>     AddOption("--two", nargs=2)
>     print(GetOption("one"), GetOption("two"))
>
> When I run SCons I get the following
>
>     $ scons -Q
>     (None, None)
>     scons: `.' is up to date.
>
>     $ scons -Q --one=a
>     ('a', None)
>     scons: `.' is up to date.
>
>     $ scons -Q --one=a --two b c
>     usage: scons [OPTION] [TARGET] ...
>
>     SCons Error: --two option requires 2 arguments
>
>     $ scons -Q --two b c
>     usage: scons [OPTION] [TARGET] ...
>
>     SCons Error: --two option requires 2 arguments
>
>     $ scons -Q --two b c --one=a
>     usage: scons [OPTION] [TARGET] ...
>
>     SCons Error: --two option requires 2 arguments
>
> I am trying to figure out why I cannot add the second option.  When I
> remove the first call to AddOption, the second (AddOption("two")) does the
> right thing.  If I remove the `nargs` option and use the `=' as described
> in thread [1], the error goes away.  Why would this be the case?
>
> I noted from the User's Manual that the parser is a subclass of the
> `optparse.Parser`, and the man page states AddOption supports the options
> for `optparse.add_option`, so I thought `nargs` would work.  I tried
> walking the code with --debug=pdb, but I could not locate which call to
> AddOption registered the options.  Any thoughts on where I should continue
> my search on why this is happening?
>
> Thanks,
>
> Keith
>
> [1]:
> https://pairlist4.pair.net/pipermail/scons-users/2014-September/002989.html
>
> --
> Keith F Prussing
> _______________________________________________
> 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/20190314/eea5e33c/attachment.html>


More information about the Scons-users mailing list