Make sethelp edit also work without specifying a starting string.
This commit is contained in:
parent
7e7ca06530
commit
dd516a290c
1 changed files with 22 additions and 9 deletions
|
|
@ -256,6 +256,7 @@ def _loadhelp(caller):
|
||||||
|
|
||||||
def _savehelp(caller, buffer):
|
def _savehelp(caller, buffer):
|
||||||
entry = caller.db._editing_help
|
entry = caller.db._editing_help
|
||||||
|
caller.msg("Saved help entry.")
|
||||||
if entry:
|
if entry:
|
||||||
entry.entrytext = buffer
|
entry.entrytext = buffer
|
||||||
|
|
||||||
|
|
@ -269,7 +270,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
Edit the help database.
|
Edit the help database.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@help[/switches] <topic>[[;alias;alias][,category[,locks]] = <text>
|
@help[/switches] <topic>[[;alias;alias][,category[,locks]] [= <text>]
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
edit - open a line editor to edit the topic's help text.
|
edit - open a line editor to edit the topic's help text.
|
||||||
|
|
@ -282,6 +283,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
@sethelp throw = This throws something at ...
|
@sethelp throw = This throws something at ...
|
||||||
@sethelp/append pickpocketing,Thievery = This steals ...
|
@sethelp/append pickpocketing,Thievery = This steals ...
|
||||||
@sethelp/replace pickpocketing, ,attr(is_thief) = This steals ...
|
@sethelp/replace pickpocketing, ,attr(is_thief) = This steals ...
|
||||||
|
@sethelp/edit thievery
|
||||||
|
|
||||||
This command manipulates the help database. A help entry can be created,
|
This command manipulates the help database. A help entry can be created,
|
||||||
appended/merged to and deleted. If you don't assign a category, the
|
appended/merged to and deleted. If you don't assign a category, the
|
||||||
|
|
@ -329,6 +331,25 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
lockstring = ",".join(lhslist[2:]) if nlist > 2 else "view:all()"
|
lockstring = ",".join(lhslist[2:]) if nlist > 2 else "view:all()"
|
||||||
category = category.lower()
|
category = category.lower()
|
||||||
|
|
||||||
|
if 'edit' in switches:
|
||||||
|
# open the line editor to edit the helptext. No = is needed.
|
||||||
|
if old_entry:
|
||||||
|
topicstr = old_entry.key
|
||||||
|
if self.rhs:
|
||||||
|
# we assume append here.
|
||||||
|
old_entry.entrytext += "\n%s" % self.rhs
|
||||||
|
helpentry = old_entry
|
||||||
|
else:
|
||||||
|
helpentry = create.create_help_entry(topicstr,
|
||||||
|
self.rhs, category=category,
|
||||||
|
locks=lockstring,aliases=aliases)
|
||||||
|
self.caller.db._editing_help = helpentry
|
||||||
|
|
||||||
|
EvEditor(self.caller, loadfunc=_loadhelp, savefunc=_savehelp,
|
||||||
|
quitfunc=_quithelp, key="topic {}".format(topicstr),
|
||||||
|
persistent=True)
|
||||||
|
return
|
||||||
|
|
||||||
if 'append' in switches or "merge" in switches or "extend" in switches:
|
if 'append' in switches or "merge" in switches or "extend" in switches:
|
||||||
# merge/append operations
|
# merge/append operations
|
||||||
if not old_entry:
|
if not old_entry:
|
||||||
|
|
@ -344,14 +365,6 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
||||||
old_entry.aliases.add(aliases)
|
old_entry.aliases.add(aliases)
|
||||||
self.msg("Entry updated:\n%s%s" % (old_entry.entrytext, aliastxt))
|
self.msg("Entry updated:\n%s%s" % (old_entry.entrytext, aliastxt))
|
||||||
return
|
return
|
||||||
if 'edit' in switches:
|
|
||||||
# open the line editor to edit the helptext
|
|
||||||
if old_entry:
|
|
||||||
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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue