diff options
author | Martin Nagy <mnagy@redhat.com> | 2008-08-15 18:08:01 +0200 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2008-09-11 23:34:01 +0200 |
commit | 885103c32127d10250564e25c5895464fb366f9e (patch) | |
tree | 5db92cd0d4282b3e1aacbfc04c9d076a0d515bec /ipa-admintools/ipa-moduser | |
parent | 57669ba43224eee0d90556aeea03d14873b4bd7f (diff) | |
download | freeipa-885103c32127d10250564e25c5895464fb366f9e.tar.gz freeipa-885103c32127d10250564e25c5895464fb366f9e.tar.xz freeipa-885103c32127d10250564e25c5895464fb366f9e.zip |
Rework config.py and change cli tools. Maintain order of IPA servers from command line, config and DNS. Parse options before detecting IPA configuration. Don't ignore rest of the options if one is missing in ipa.conf. Drop the --usage options, we will rely on --help. Fixes: 458869, 459070, 458980, 459234
Diffstat (limited to 'ipa-admintools/ipa-moduser')
-rw-r--r-- | ipa-admintools/ipa-moduser | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/ipa-admintools/ipa-moduser b/ipa-admintools/ipa-moduser index 4ea40632..5f0bc6af 100644 --- a/ipa-admintools/ipa-moduser +++ b/ipa-admintools/ipa-moduser @@ -41,16 +41,13 @@ error was: """ % sys.exc_value sys.exit(1) -def usage(): - print "ipa-moduser [--list]" - print "ipa-moduser [-a|--activate] [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell STRING] [--addattr attribute=value] [--delattr attribute] [--setattr attribute=value] [-v|--verbose] user" - sys.exit(1) - def set_add_usage(which): print "%s option usage: --%s NAME=VALUE" % (which, which) def parse_options(): - parser = OptionParser() + usage = "%prog --list\n" + usage = "%prog [options] user" + parser = OptionParser(usage=usage, formatter=ipa.config.IPAFormatter()) parser.add_option("-a", "--activate", dest="activate", action="store_true", help="Activate the user") parser.add_option("-c", "--gecos", dest="gecos", @@ -75,13 +72,16 @@ def parse_options(): help="List common attributes (this is not an exhaustive list)") parser.add_option("-M", "--mailAddress", dest="mail", help="Set user's e-mail address") - parser.add_option("--usage", action="store_true", - help="Program usage") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Verbose output of the XML-RPC connection") - args = ipa.config.init_config(sys.argv) - options, args = parser.parse_args(args) + ipa.config.add_standard_options(parser) + options, args = parser.parse_args() + + if not options.list: + ipa.config.verify_args(parser, args, "user") + + ipa.config.init_config(options) return options, args @@ -108,10 +108,7 @@ def main(): print x return 0 - if options.usage or len(args) != 2: - usage() - - username = args[1] + username = args[0] client = ipaclient.IPAClient(verbose=options.verbose) try: @@ -197,7 +194,7 @@ def main(): if len(s) != 2: set_add_usage("set") sys.exit(1) - (attr,value) = s + (attr,value) = s user.setValue(attr, value) if options.addattr: |