Allow command options to be set from environment variables

Extend the Command base class to allow options to be set from values
in environment variables, if the user has not given the option on the
command line and the environment variable is set.

Derived classes of Command can override the implementation of the method
_GetEnvironmentOptions to configure which of its options may be set from
environment variables.

Change-Id: I7c780bcf9644d6567893d9930984c054bce7351e
This commit is contained in:
David Pursehouse
2012-11-16 09:33:39 +09:00
parent a67df63ef1
commit b148ac9d9a
2 changed files with 41 additions and 0 deletions

View File

@ -120,6 +120,7 @@ class _Repo(object):
return 1
copts, cargs = cmd.OptionParser.parse_args(argv)
copts = cmd.ReadEnvironmentOptions(copts)
if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
config = cmd.manifest.globalConfig