Multiple AddOption with arguments

Keith F Prussing <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <[email protected]>
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
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.