mirror of
https://github.com/nettitude/PoshC2
synced 2026-06-08 16:22:47 +00:00
22 lines
613 B
Python
22 lines
613 B
Python
from typing import Optional
|
|
|
|
from prompt_toolkit.auto_suggest import Suggestion, AutoSuggest
|
|
from prompt_toolkit.document import Document
|
|
|
|
|
|
class AutoSuggestFromPoshExamples(AutoSuggest):
|
|
"""
|
|
Give suggestions based on the lines examples of the helptext.
|
|
"""
|
|
|
|
def __init__(self, examples):
|
|
self.examples = examples
|
|
|
|
def get_suggestion(self, buffer: "Buffer", document: Document) -> Optional[Suggestion]:
|
|
|
|
for example in self.examples:
|
|
if example.startswith(document.text.strip()):
|
|
return Suggestion(example[len(document.text):])
|
|
|
|
return None
|