Made some updates to the tag command. Among other things, resolves #993.
This commit is contained in:
parent
4fafa22e86
commit
d42e971be6
1 changed files with 22 additions and 8 deletions
|
|
@ -2404,10 +2404,10 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@tag[/del] <obj> [= <tag>[:<category>]]
|
@tag[/del] <obj> [= <tag>[:<category>]]
|
||||||
@tag/search <tag>
|
@tag/search <tag>[:<category]
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
search - return all objects
|
search - return all objects with a given Tag
|
||||||
del - remove the given tag. If no tag is specified,
|
del - remove the given tag. If no tag is specified,
|
||||||
clear all tags on object.
|
clear all tags on object.
|
||||||
|
|
||||||
|
|
@ -2421,8 +2421,10 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
key = "@tag"
|
key = "@tag"
|
||||||
|
aliases = ["@tags"]
|
||||||
locks = "cmd:perm(tag) or perm(Builders)"
|
locks = "cmd:perm(tag) or perm(Builders)"
|
||||||
help_category = "Building"
|
help_category = "Building"
|
||||||
|
arg_regex = r"(/\w+?(\s|$))|\s|$"
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"Implement the @tag functionality"
|
"Implement the @tag functionality"
|
||||||
|
|
@ -2463,14 +2465,26 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
||||||
category = None
|
category = None
|
||||||
if ":" in tag:
|
if ":" in tag:
|
||||||
tag, category = [part.strip() for part in tag.split(":", 1)]
|
tag, category = [part.strip() for part in tag.split(":", 1)]
|
||||||
|
if obj.tags.get(tag, category=category):
|
||||||
obj.tags.remove(tag, category=category)
|
obj.tags.remove(tag, category=category)
|
||||||
string = "Removed tag '%s'%s from %s (if it existed)" % (tag,
|
string = "Removed tag '%s'%s from %s." % (
|
||||||
|
tag,
|
||||||
|
" (category: %s)" % category if category else "",
|
||||||
|
obj)
|
||||||
|
else:
|
||||||
|
string = "No tag '%s'%s to delete on %s." % (
|
||||||
|
tag,
|
||||||
" (category: %s)" % category if category else "",
|
" (category: %s)" % category if category else "",
|
||||||
obj)
|
obj)
|
||||||
else:
|
else:
|
||||||
# no tag specified, clear all tags
|
# no tag specified, clear all tags
|
||||||
|
old_tags = ["%s%s" % (tag, " (category: %s" % category if category else "")
|
||||||
|
for tag, category in obj.tags.all(return_key_and_category=True)]
|
||||||
|
if old_tags:
|
||||||
obj.tags.clear()
|
obj.tags.clear()
|
||||||
string = "Cleared all tags from from %s." % obj
|
string = "Cleared all tags from %s: %s" % (obj, ", ".join(old_tags))
|
||||||
|
else:
|
||||||
|
string = "No Tags to clear on %s." % obj
|
||||||
self.caller.msg(string)
|
self.caller.msg(string)
|
||||||
return
|
return
|
||||||
# no search/deletion
|
# no search/deletion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue