diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-17 18:50:30 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-17 18:50:30 -0700 |
commit | 8474bd01da13b9b72ba06e832d4c35ef6ccf5c9e (patch) | |
tree | 063573d060a7de4f2833a7a608b48f5d2719a435 | |
parent | 5c16047092652d2d56c86d83259c56eff883b485 (diff) | |
download | freeipa-8474bd01da13b9b72ba06e832d4c35ef6ccf5c9e.tar.gz freeipa-8474bd01da13b9b72ba06e832d4c35ef6ccf5c9e.tar.xz freeipa-8474bd01da13b9b72ba06e832d4c35ef6ccf5c9e.zip |
Command.get_defaults() now returns param.default if param.type is a Bool
-rw-r--r-- | ipalib/cli.py | 6 | ||||
-rw-r--r-- | ipalib/frontend.py | 2 | ||||
-rw-r--r-- | tests/test_ipalib/test_frontend.py | 8 |
3 files changed, 10 insertions, 6 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 1c7256a2a..909e2acbc 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -693,8 +693,10 @@ class CLI(object): help=option.doc, ) if isinstance(option.type, ipa_types.Bool): - o.action = 'store_true' - o.default = option.default + if option.default is True: + o.action = 'store_false' + else: + o.action = 'store_true' o.type = None parser.add_option(o) return parser diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 3ae143ef3..61cba513b 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -651,6 +651,8 @@ class Command(plugable.Plugin): if kw.get(param.name, None) is None: if param.required: yield (param.name, param.get_default(**kw)) + elif isinstance(param.type, ipa_types.Bool): + yield (param.name, param.default) else: yield (param.name, None) diff --git a/tests/test_ipalib/test_frontend.py b/tests/test_ipalib/test_frontend.py index 771fdb911..44d8e54cc 100644 --- a/tests/test_ipalib/test_frontend.py +++ b/tests/test_ipalib/test_frontend.py @@ -832,8 +832,8 @@ class test_LocalOrRemote(ClassChecker): api.register(example) api.finalize() cmd = api.Command.example - assert cmd() == ('execute', (None,), dict(server=None)) - assert cmd('var') == ('execute', (u'var',), dict(server=None)) + assert cmd() == ('execute', (None,), dict(server=False)) + assert cmd('var') == ('execute', (u'var',), dict(server=False)) assert cmd(server=True) == ('forward', (None,), dict(server=True)) assert cmd('var', server=True) == \ ('forward', (u'var',), dict(server=True)) @@ -843,8 +843,8 @@ class test_LocalOrRemote(ClassChecker): api.register(example) api.finalize() cmd = api.Command.example - assert cmd() == ('execute', (None,), dict(server=None)) - assert cmd('var') == ('execute', (u'var',), dict(server=None)) + assert cmd() == ('execute', (None,), dict(server=False)) + assert cmd('var') == ('execute', (u'var',), dict(server=False)) assert cmd(server=True) == ('execute', (None,), dict(server=True)) assert cmd('var', server=True) == \ ('execute', (u'var',), dict(server=True)) |