MCPcopy Create free account
hub / github.com/dbcli/mycli / suggest_special

Function suggest_special

mycli/packages/completion_engine.py:766–819  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

764
765
766def suggest_special(text: str) -> list[dict[str, Any]]:
767 text = text.lstrip()
768 cmd, _separator, _arg = parse_special_command(text)
769
770 if cmd == text:
771 # Trying to complete the special command itself
772 return [{"type": "special"}]
773
774 if cmd in ("\\u", "/u", "\\r", "/r"):
775 return [{"type": "database"}]
776
777 if cmd.lower() in ('use', '/use', 'connect', '/connect'):
778 return [{'type': 'database'}]
779
780 if cmd in (r'\T', '/T', r'\Tr', '/Tr'):
781 return [{"type": "table_format"}]
782
783 if cmd.lower() in ('tableformat', '/tableformat', 'redirectformat', '/redirectformat'):
784 return [{"type": "table_format"}]
785
786 if cmd in ["\\f", "/f", "\\fs", "/fs", "\\fd", "/fd"]:
787 return [{"type": "favoritequery"}]
788
789 if cmd in ["\\dt", "/dt", "\\dt+", "/dt+"]:
790 return [
791 {"type": "table", "schema": []},
792 {"type": "view", "schema": []},
793 {"type": "schema"},
794 ]
795 elif cmd.lower() in [
796 r'\.',
797 r'/.',
798 'source',
799 '/source',
800 r'\o',
801 '/o',
802 r'\once',
803 '/once',
804 'tee',
805 '/tee',
806 ]:
807 return [{"type": "file_name"}]
808 # todo: why is \edit case-sensitive?
809 elif cmd in [
810 r'\e',
811 '/e',
812 r'\edit',
813 '/edit',
814 ]:
815 return [{"type": "file_name"}]
816 if cmd in ["\\llm", "/llm", "\\ai", "/ai"]:
817 return [{"type": "llm"}]
818
819 return [{"type": "keyword"}, {"type": "special"}]
820
821
822def suggest_based_on_last_token(

Callers 2

test_suggest_specialFunction · 0.90
suggest_typeFunction · 0.85

Calls 1

parse_special_commandFunction · 0.90

Tested by 1

test_suggest_specialFunction · 0.72