[Scons-users] Multiple AddOption with arguments
    Keith F Prussing 
    kprussing74 at gmail.com
       
    Thu Mar 14 13:02:14 EDT 2019
    
    
  
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
    
    
More information about the Scons-users
mailing list