fantasyfly / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 1 forks source link

Lose the use of optparse #195

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
optparse is deprecated in python2.7 and 3.2+. Argparse has replaced it (and is 
available on pypi for older versions). 

The use of optparse should be gradually deprecated in repo. Of course this 
needs to be done carefully since others write subcommands. 

A wrapper can be written around argparse to enable the most common uses of 
optparse so we don't break everyones commands. This won't work for all though, 
such as with callbacks that use parser.largs or rargs.

A class attribute can also be set to say if a command fully supports argparse, 
enabling us to skip the wrapper altogether.

Anything that doesn't touch on subcommands can be directly converted to use 
argparse safely.

Since argparse supports subparsers, it will simplify the the process used for 
selecting the subcommand.

In time, support for optparse should be fully removed, starting with warnings 
when optparse methods are used, then forcing an option to be set to allow 
optparse methods to be used, finally fully removing the wrapper.
Since optparse isn't set to be removed from py3.5, I would recommend a time 
frame of 2 years from when the subcommands are changed to use argparse. 

Original issue reported on code.google.com by anthonyd...@gmail.com on 21 Feb 2015 at 6:27