diff options
author | Martin Nagy <mnagy@redhat.com> | 2008-10-17 22:55:03 +0200 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2008-10-17 23:11:51 +0200 |
commit | 3a80297b04d6fbfd2367ec76c5651d20293adccc (patch) | |
tree | 8f10d8b3c490dec9b29077ffaa4052bb03c27fea /ipalib/cli.py | |
parent | ae8370be44d95b9f6793ded46ef81126aebef3e0 (diff) | |
download | freeipa.git-3a80297b04d6fbfd2367ec76c5651d20293adccc.tar.gz freeipa.git-3a80297b04d6fbfd2367ec76c5651d20293adccc.tar.xz freeipa.git-3a80297b04d6fbfd2367ec76c5651d20293adccc.zip |
Reworking Environment, moved it to config.py
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r-- | ipalib/cli.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 5dd2c44f..07956e0a 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -25,11 +25,12 @@ import re import sys import code import optparse + import frontend import errors import plugable import ipa_types -import config +from config import set_default_env, read_config def exit_error(error): sys.exit('ipa: ERROR: %s' % error) @@ -207,7 +208,6 @@ class CLI(object): self.__api = api self.__all_interactive = False self.__not_interactive = False - self.__config = None def __get_api(self): return self.__api @@ -256,9 +256,8 @@ class CLI(object): def run(self): self.finalize() - (args, env_dict) = self.parse_globals() - env_dict.update(config.read_config(self.__config)) - self.api.env.update(config.generate_env(env_dict)) + set_default_env(self.api.env) + args = self.parse_globals() if len(args) < 1: self.print_commands() print 'Usage: ipa [global-options] COMMAND' @@ -329,7 +328,6 @@ class CLI(object): return parser def parse_globals(self, argv=sys.argv[1:]): - env_dict = {} parser = optparse.OptionParser() parser.disable_interspersed_args() parser.add_option('-a', dest='interactive', action='store_true', @@ -348,20 +346,23 @@ class CLI(object): self.__all_interactive = True elif options.interactive == False: self.__not_interactive = True - if options.config_file: - self.__config = options.config_file + if options.verbose != None: + self.api.env.verbose = True if options.environment: + env_dict = {} for a in options.environment.split(','): a = a.split('=', 1) if len(a) < 2: parser.error('badly specified environment string,'\ 'use var1=val1[,var2=val2]..') env_dict[a[0].strip()] = a[1].strip() - if options.verbose != None: - env_dict.update(verbose=True) - - return (args, env_dict) + self.api.env.update(env_dict, True) + if options.config_file: + self.api.env.update(read_config(options.config_file), True) + else: + self.api.env.update(read_config(), True) + return args def get_usage(self, cmd): return ' '.join(self.get_usage_iter(cmd)) |