Correct help query on @, fix reset hook call.
This commit is contained in:
parent
5ff69d7086
commit
88fff7c57b
5 changed files with 20 additions and 15 deletions
|
|
@ -103,9 +103,8 @@ def _init_command(cls, **kwargs):
|
||||||
# strip the @- etc to allow help to be agnostic
|
# strip the @- etc to allow help to be agnostic
|
||||||
stripped_key = cls.key[1:] if cls.key and cls.key[0] in CMD_IGNORE_PREFIXES else ""
|
stripped_key = cls.key[1:] if cls.key and cls.key[0] in CMD_IGNORE_PREFIXES else ""
|
||||||
stripped_aliases = (
|
stripped_aliases = (
|
||||||
" ".join(al for al in cls.aliases
|
" ".join(al[1:] if al and al[0] in CMD_IGNORE_PREFIXES else al
|
||||||
if al and al[0] in CMD_IGNORE_PREFIXES for al in cls.aliases)
|
for al in cls.aliases))
|
||||||
)
|
|
||||||
cls.search_index_entry = {
|
cls.search_index_entry = {
|
||||||
"key": cls.key,
|
"key": cls.key,
|
||||||
"aliases": " ".join(cls.aliases),
|
"aliases": " ".join(cls.aliases),
|
||||||
|
|
|
||||||
|
|
@ -1945,7 +1945,8 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
||||||
update - *only* re-run at_object_creation on this object
|
update - *only* re-run at_object_creation on this object
|
||||||
meaning locks or other properties set later may remain.
|
meaning locks or other properties set later may remain.
|
||||||
reset - clean out *all* the attributes and properties on the
|
reset - clean out *all* the attributes and properties on the
|
||||||
object - basically making this a new clean object.
|
object - basically making this a new clean object. This will also
|
||||||
|
reset cmdsets!
|
||||||
force - change to the typeclass also if the object
|
force - change to the typeclass also if the object
|
||||||
already has a typeclass of the same name.
|
already has a typeclass of the same name.
|
||||||
list - show available typeclasses. Only typeclasses in modules actually
|
list - show available typeclasses. Only typeclasses in modules actually
|
||||||
|
|
@ -2155,7 +2156,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
update = "update" in self.switches
|
update = "update" in self.switches
|
||||||
reset = "reset" in self.switches
|
reset = "reset" in self.switches
|
||||||
hooks = "at_object_creation" if update else "all"
|
hooks = "at_object_creation" if update and not reset else "all"
|
||||||
old_typeclass_path = obj.typeclass_path
|
old_typeclass_path = obj.typeclass_path
|
||||||
|
|
||||||
# special prompt for the user in cases where we want
|
# special prompt for the user in cases where we want
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
|
||||||
subtopics = ''
|
subtopics = ''
|
||||||
|
|
||||||
if suggested:
|
if suggested:
|
||||||
|
suggested = sorted(suggested)
|
||||||
if click_topics:
|
if click_topics:
|
||||||
suggested = [f"|lchelp {sug}|lt|w{sug}|n|le" for sug in suggested]
|
suggested = [f"|lchelp {sug}|lt|w{sug}|n|le" for sug in suggested]
|
||||||
else:
|
else:
|
||||||
|
|
@ -544,11 +545,15 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# search for a specific entry. We need to check for 'read' access here before # building the
|
# search for a specific entry. We need to check for 'read' access here before
|
||||||
# set of possibilities.
|
# building the set of possibilities.
|
||||||
cmd_help_topics, db_help_topics, file_help_topics = \
|
cmd_help_topics, db_help_topics, file_help_topics = \
|
||||||
self.collect_topics(caller, mode='query')
|
self.collect_topics(caller, mode='query')
|
||||||
|
|
||||||
|
# get a collection of all keys + aliases to be able to strip prefixes like @
|
||||||
|
key_and_aliases = set(
|
||||||
|
chain(*(cmd._keyaliases for cmd in cmd_help_topics.values())))
|
||||||
|
|
||||||
# db-help topics takes priority over file-help
|
# db-help topics takes priority over file-help
|
||||||
file_db_help_topics = {**file_help_topics, **db_help_topics}
|
file_db_help_topics = {**file_help_topics, **db_help_topics}
|
||||||
|
|
||||||
|
|
@ -585,12 +590,13 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
|
||||||
suggestion_maxnum=self.suggestion_maxnum,
|
suggestion_maxnum=self.suggestion_maxnum,
|
||||||
fields=search_fields
|
fields=search_fields
|
||||||
)
|
)
|
||||||
|
|
||||||
if suggestions:
|
if suggestions:
|
||||||
help_text += (
|
help_text += (
|
||||||
"\n... But matches where found within the help "
|
"\n... But matches where found within the help "
|
||||||
"texts of the suggestions below.")
|
"texts of the suggestions below.")
|
||||||
# break
|
suggestions = [self.strip_cmd_prefix(sugg, key_and_aliases)
|
||||||
|
for sugg in suggestions]
|
||||||
|
break
|
||||||
|
|
||||||
output = self.format_help_entry(
|
output = self.format_help_entry(
|
||||||
topic=None, # this will give a no-match style title
|
topic=None, # this will give a no-match style title
|
||||||
|
|
@ -683,8 +689,6 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
|
||||||
# we reached the bottom of the topic tree
|
# we reached the bottom of the topic tree
|
||||||
help_text = subtopic_map[None]
|
help_text = subtopic_map[None]
|
||||||
|
|
||||||
# get a collection of all keys + aliases to be able to strip prefixes like @
|
|
||||||
key_and_aliases = set(chain(*(cmd._keyaliases for cmd in cmd_help_topics.values())))
|
|
||||||
topic = self.strip_cmd_prefix(topic, key_and_aliases)
|
topic = self.strip_cmd_prefix(topic, key_and_aliases)
|
||||||
if subtopics:
|
if subtopics:
|
||||||
aliases = None
|
aliases = None
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def help_search_with_index(query, candidate_entries, suggestion_maxnum=5, fields
|
||||||
from lunr import get_default_builder as _LUNR_GET_BUILDER
|
from lunr import get_default_builder as _LUNR_GET_BUILDER
|
||||||
from lunr import stop_word_filter
|
from lunr import stop_word_filter
|
||||||
from lunr.stemmer import stemmer
|
from lunr.stemmer import stemmer
|
||||||
from lunr.trimmer import trimmer
|
# from lunr.trimmer import trimmer
|
||||||
|
|
||||||
# pre-create a lunr index-builder pipeline where we've removed some of
|
# pre-create a lunr index-builder pipeline where we've removed some of
|
||||||
# the stop-words from the default in lunr.
|
# the stop-words from the default in lunr.
|
||||||
|
|
|
||||||
|
|
@ -572,8 +572,8 @@ class TypedObject(SharedMemoryModel):
|
||||||
will be cleared.
|
will be cleared.
|
||||||
run_start_hooks (str or None, optional): This is either None,
|
run_start_hooks (str or None, optional): This is either None,
|
||||||
to not run any hooks, "all" to run all hooks defined by
|
to not run any hooks, "all" to run all hooks defined by
|
||||||
at_first_start, or a string giving the name of the hook
|
at_first_start, or a string with space-separated hook-names to run
|
||||||
to run (for example 'at_object_creation'). This will
|
(for example 'at_object_creation'). This will
|
||||||
always be called without arguments.
|
always be called without arguments.
|
||||||
no_default (bool, optiona): If set, the swapper will not
|
no_default (bool, optiona): If set, the swapper will not
|
||||||
allow for swapping to a default typeclass in case the
|
allow for swapping to a default typeclass in case the
|
||||||
|
|
@ -621,7 +621,8 @@ class TypedObject(SharedMemoryModel):
|
||||||
self.at_first_save()
|
self.at_first_save()
|
||||||
elif run_start_hooks:
|
elif run_start_hooks:
|
||||||
# a custom hook-name to call.
|
# a custom hook-name to call.
|
||||||
getattr(self, run_start_hooks)()
|
for start_hook in str(run_start_hooks).split():
|
||||||
|
getattr(self, run_start_hooks)()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Lock / permission methods
|
# Lock / permission methods
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue