MCPcopy Index your code
hub / github.com/secdev/scapy / CLICompleter

Class CLICompleter

scapy/utils.py:3791–3811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3789 from prompt_toolkit.completion import Completer, Completion
3790
3791 class CLICompleter(Completer):
3792 def get_completions(cmpl, document, complete_event): # type: ignore
3793 if not complete_event.completion_requested:
3794 # Only activate when the user does <TAB>
3795 return
3796 parts = document.text.split(" ")
3797 cmd = parts[0].lower()
3798 if cmd not in self.commands:
3799 # We are trying to complete the command
3800 for possible_cmd in (x for x in self.commands if x.startswith(cmd)):
3801 yield Completion(possible_cmd, start_position=-len(cmd))
3802 else:
3803 # We are trying to complete the command content
3804 if len(parts) == 1:
3805 return
3806 args, _, _ = self._parseallargs(self.commands[cmd], cmd, parts[1:])
3807 arg = " ".join(args)
3808 if cmd in self.commands_complete:
3809 for possible_arg in self.commands_complete[cmd](self, arg):
3810 yield Completion(possible_arg, start_position=-len(arg))
3811 return
3812 return CLICompleter()
3813
3814 def loop(self, debug: int = 0) -> None:

Callers 1

_completerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…