Show result when a setting is unset
This commit is contained in:
parent
5611f4ceef
commit
2947b92792
1 changed files with 4 additions and 0 deletions
|
@ -13,6 +13,7 @@ class ConfigSettingInexistent(Exception):
|
||||||
class ConfigResults(enum.Enum):
|
class ConfigResults(enum.Enum):
|
||||||
Changed = 1
|
Changed = 1
|
||||||
Retrieved = 2
|
Retrieved = 2
|
||||||
|
Removed = 3
|
||||||
class ConfigResult(object):
|
class ConfigResult(object):
|
||||||
def __init__(self, result, data=None):
|
def __init__(self, result, data=None):
|
||||||
self.result = result
|
self.result = result
|
||||||
|
@ -242,6 +243,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if unset:
|
if unset:
|
||||||
setting = setting[1:]
|
setting = setting[1:]
|
||||||
target.del_setting(setting)
|
target.del_setting(setting)
|
||||||
|
return ConfigResult(ConfigResults.Removed)
|
||||||
else:
|
else:
|
||||||
return ConfigResult(ConfigResults.Retrieved, existing_value)
|
return ConfigResult(ConfigResults.Retrieved, existing_value)
|
||||||
else:
|
else:
|
||||||
|
@ -308,6 +310,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
event["stdout"].write("Config changed")
|
event["stdout"].write("Config changed")
|
||||||
elif result.result == ConfigResults.Retrieved:
|
elif result.result == ConfigResults.Retrieved:
|
||||||
event["stdout"].write("%s: %s" % (setting, result.data))
|
event["stdout"].write("%s: %s" % (setting, result.data))
|
||||||
|
elif result.result == ConfigResults.Removed:
|
||||||
|
event["stdout"].write("Unset setting")
|
||||||
else:
|
else:
|
||||||
event["stdout"].write("Available config: %s" %
|
event["stdout"].write("Available config: %s" %
|
||||||
", ".join(export_settings.keys()))
|
", ".join(export_settings.keys()))
|
||||||
|
|
Loading…
Reference in a new issue