Fixes the searching by category. Resolves #488.
This commit is contained in:
parent
4b1b842bd2
commit
e2130cd3e8
1 changed files with 11 additions and 8 deletions
|
|
@ -2135,13 +2135,15 @@ class CmdTag(MuxCommand):
|
||||||
Switches:
|
Switches:
|
||||||
search - return all objects
|
search - return all objects
|
||||||
del - remove the given tag. If no tag is specified,
|
del - remove the given tag. If no tag is specified,
|
||||||
clear all tags.
|
clear all tags on object.
|
||||||
|
|
||||||
Manipulates and lists tags on objects. Tags allow for quick
|
Manipulates and lists tags on objects. Tags allow for quick
|
||||||
grouping of and searching for objects. If only <obj> is given,
|
grouping of and searching for objects. If only <obj> is given,
|
||||||
list all tags on the object. If /search is used, list objects
|
list all tags on the object. If /search is used, list objects
|
||||||
with the given tag.
|
with the given tag.
|
||||||
The category can be used for grouping tags themselves.
|
The category can be used for grouping tags themselves, but it
|
||||||
|
should be used with restrain - tags on their own are usually
|
||||||
|
enough to for most grouping schemes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
key = "@tag"
|
key = "@tag"
|
||||||
|
|
@ -2158,19 +2160,20 @@ class CmdTag(MuxCommand):
|
||||||
# search by tag
|
# search by tag
|
||||||
tag = self.args
|
tag = self.args
|
||||||
category = None
|
category = None
|
||||||
search_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)]
|
||||||
search_category = "object_%s" % category
|
|
||||||
#print "tag search:", tag, search_category
|
#print "tag search:", tag, search_category
|
||||||
objs = search.search_tag(tag, category=search_category)
|
objs = search.search_tag(tag, category=category)
|
||||||
nobjs = len(objs)
|
nobjs = len(objs)
|
||||||
if nobjs > 0:
|
if nobjs > 0:
|
||||||
string = "Found %i object%s with tag '%s'%s:\n %s" % (nobjs,
|
catstr = " (category: '{w%s{n')" % category if category else \
|
||||||
|
("" if nobjs == 1 else " (may have different tag categories)")
|
||||||
|
matchstr = ", ".join("{w%s{n(#%i)" % (o.key, o.dbid) for o in objs)
|
||||||
|
|
||||||
|
string = "Found {w%i{n object%s with tag '{w%s{n'%s:\n %s" % (nobjs,
|
||||||
"s" if nobjs > 1 else "",
|
"s" if nobjs > 1 else "",
|
||||||
tag,
|
tag,
|
||||||
" (category: %s)" % category if category else "",
|
catstr, matchstr)
|
||||||
", ".join("%s(#%i)" % (o.key, o.dbid) for o in objs))
|
|
||||||
else:
|
else:
|
||||||
string = "No objects found with tag '%s%s'." % (tag,
|
string = "No objects found with tag '%s%s'." % (tag,
|
||||||
" (category: %s)" % category if category else "")
|
" (category: %s)" % category if category else "")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue