Allow to add a service description on "yunohost service add" (#529)

* [enh] add a service description with YML file

* moins "espace"
This commit is contained in:
irina11y 2018-09-02 18:18:01 +02:00 committed by Alexandre Aubin
parent 8b8d4cc19a
commit e56616af5e
2 changed files with 12 additions and 2 deletions

View file

@ -1136,6 +1136,9 @@ service:
full: --runlevel full: --runlevel
help: Runlevel priority of the service help: Runlevel priority of the service
type: int type: int
-d:
full: --description
help: Description of the service
### service_remove() ### service_remove()
remove: remove:

View file

@ -50,7 +50,7 @@ MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock"
logger = log.getActionLogger('yunohost.service') logger = log.getActionLogger('yunohost.service')
def service_add(name, status=None, log=None, runlevel=None): def service_add(name, status=None, log=None, runlevel=None, description=None):
""" """
Add a custom service Add a custom service
@ -59,6 +59,7 @@ def service_add(name, status=None, log=None, runlevel=None):
status -- Custom status command status -- Custom status command
log -- Absolute path to log file to display log -- Absolute path to log file to display
runlevel -- Runlevel priority of the service runlevel -- Runlevel priority of the service
description -- description of the service
""" """
services = _get_services() services = _get_services()
@ -74,6 +75,9 @@ def service_add(name, status=None, log=None, runlevel=None):
if runlevel is not None: if runlevel is not None:
services[name]['runlevel'] = runlevel services[name]['runlevel'] = runlevel
if description is not None:
services[name]['description'] = description
try: try:
_save_services(services) _save_services(services)
except: except:
@ -251,7 +255,10 @@ def service_status(names=[]):
else: else:
translation_key = "service_description_%s" % name translation_key = "service_description_%s" % name
description = m18n.n(translation_key) if "description" in services[name] is not None:
description = services[name].get("description")
else:
description = m18n.n(translation_key)
# that mean that we don't have a translation for this string # that mean that we don't have a translation for this string
# that's the only way to test for that for now # that's the only way to test for that for now