Re: Multiple AddOption with arguments

Bill Deegan <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CAEyG4CG8Vj915mHfpTAWHcX8-Xh230NMyBT6dgh=k=NrmK5_MA@mail.gmail.com>
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 <[email protected]>
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
> [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.