Allow to create @help entries and edit the content directly
This commit is contained in:
parent
3998ed1069
commit
7e7ca06530
1 changed files with 16 additions and 14 deletions
|
|
@ -247,23 +247,20 @@ class CmdHelp(Command):
|
||||||
self.msg(self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions))
|
self.msg(self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions))
|
||||||
|
|
||||||
|
|
||||||
def loadhelp(caller):
|
def _loadhelp(caller):
|
||||||
"""Load the help entry to edit."""
|
|
||||||
entry = caller.db._editing_help
|
entry = caller.db._editing_help
|
||||||
if entry:
|
if entry:
|
||||||
return entry.entrytext
|
return entry.entrytext
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def savehelp(caller, buffer):
|
def _savehelp(caller, buffer):
|
||||||
"""Save the help entry."""
|
|
||||||
entry = caller.db._editing_help
|
entry = caller.db._editing_help
|
||||||
if entry:
|
if entry:
|
||||||
entry.entrytext = buffer
|
entry.entrytext = buffer
|
||||||
|
|
||||||
|
|
||||||
def quithelp(caller):
|
def _quithelp(caller):
|
||||||
"""Quit the help editor."""
|
|
||||||
caller.msg("Closing the editor.")
|
caller.msg("Closing the editor.")
|
||||||
del caller.db._editing_help
|
del caller.db._editing_help
|
||||||
|
|
||||||
|
|
@ -349,15 +346,12 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
return
|
return
|
||||||
if 'edit' in switches:
|
if 'edit' in switches:
|
||||||
# open the line editor to edit the helptext
|
# open the line editor to edit the helptext
|
||||||
if not old_entry:
|
if old_entry:
|
||||||
self.msg("Could not find topic '%s'%s." % (topicstr, aliastxt))
|
self.caller.db._editing_help = old_entry
|
||||||
|
EvEditor(self.caller, loadfunc=_loadhelp, savefunc=_savehelp,
|
||||||
|
quitfunc=_quithelp, key="topic {}".format(old_entry.key),
|
||||||
|
persistent=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.caller.db._editing_help = old_entry
|
|
||||||
EvEditor(self.caller, loadfunc=loadhelp, savefunc=savehelp,
|
|
||||||
quitfunc=quithelp, key="topic {}".format(old_entry.key),
|
|
||||||
persistent=True)
|
|
||||||
return
|
|
||||||
if 'delete' in switches or 'del' in switches:
|
if 'delete' in switches or 'del' in switches:
|
||||||
# delete the help entry
|
# delete the help entry
|
||||||
if not old_entry:
|
if not old_entry:
|
||||||
|
|
@ -392,5 +386,13 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
locks=lockstring,aliases=aliases)
|
locks=lockstring,aliases=aliases)
|
||||||
if new_entry:
|
if new_entry:
|
||||||
self.msg("Topic '%s'%s was successfully created." % (topicstr, aliastxt))
|
self.msg("Topic '%s'%s was successfully created." % (topicstr, aliastxt))
|
||||||
|
if 'edit' in switches:
|
||||||
|
# open the line editor to edit the helptext
|
||||||
|
self.caller.db._editing_help = new_entry
|
||||||
|
EvEditor(self.caller, loadfunc=_loadhelp,
|
||||||
|
savefunc=_savehelp, quitfunc=_quithelp,
|
||||||
|
key="topic {}".format(new_entry.key),
|
||||||
|
persistent=True)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self.msg("Error when creating topic '%s'%s! Contact an admin." % (topicstr, aliastxt))
|
self.msg("Error when creating topic '%s'%s! Contact an admin." % (topicstr, aliastxt))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue