MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / basic_complete

Method basic_complete

cmd2/cmd2.py:2029–2059  ·  view source on GitHub ↗

Perform completion without considering line contents or cursor position. Strings are matched directly while CompletionItems are matched against their 'text' member. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the c

(
        self,
        text: str,
        line: str,  # noqa: ARG002
        begidx: int,  # noqa: ARG002
        endidx: int,  # noqa: ARG002
        match_against: Iterable[str | CompletionItem],
        *,
        sort: bool = True,
    )

Source from the content-addressed store, hash-verified

2027 return tokens, raw_tokens
2028
2029 def basic_complete(
2030 self,
2031 text: str,
2032 line: str, # noqa: ARG002
2033 begidx: int, # noqa: ARG002
2034 endidx: int, # noqa: ARG002
2035 match_against: Iterable[str | CompletionItem],
2036 *,
2037 sort: bool = True,
2038 ) -> Completions:
2039 """Perform completion without considering line contents or cursor position.
2040
2041 Strings are matched directly while CompletionItems are matched against their 'text' member.
2042
2043 :param text: the string prefix we are attempting to match (all matches must begin with it)
2044 :param line: the current input line with leading whitespace removed
2045 :param begidx: the beginning index of the prefix text
2046 :param endidx: the ending index of the prefix text
2047 :param match_against: the items being matched against
2048 :param sort: if True, then results will be sorted. If False, then items will
2049 be in the same order they appeared in match_against.
2050 :return: a Completions object
2051 """
2052 matches: list[CompletionItem] = []
2053
2054 for item in match_against:
2055 candidate = item.text if isinstance(item, CompletionItem) else item
2056 if candidate.startswith(text):
2057 matches.append(item if isinstance(item, CompletionItem) else CompletionItem(item))
2058
2059 return Completions(items=matches, is_sorted=not sort)
2060
2061 def delimiter_complete(
2062 self,

Callers 15

delimiter_completeMethod · 0.95
complete_help_commandMethod · 0.95
_complete_flagsMethod · 0.80
_complete_argMethod · 0.80
complete_test_basicMethod · 0.80
test_basic_completionFunction · 0.80
complete_durianMethod · 0.80
complete_statesMethod · 0.80

Calls 3

CompletionItemClass · 0.85
CompletionsClass · 0.85
appendMethod · 0.80

Tested by 12

complete_test_basicMethod · 0.64
test_basic_completionFunction · 0.64
complete_durianMethod · 0.64
complete_statesMethod · 0.64
standalone_completerFunction · 0.64
flag_completerMethod · 0.64
pos_1_completerMethod · 0.64
pos_2_completerMethod · 0.64