MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / watch_command

Function watch_command

src/pyspector/cli.py:973–1129  ·  view source on GitHub ↗

Continuous watch mode: re-scan on every .py file change.

(
    path:           Path,
    severity_level: str,
    ai_scan:        bool,
    config_path:    Optional[Path],
    debounce:       float,
    debug:          bool,
)

Source from the content-addressed store, hash-verified

971@click.option(
972 "-s", "--severity", "severity_level",
973 type=click.Choice(["LOW", "MEDIUM", "HIGH", "CRITICAL"]),
974 default="LOW", show_default=True,
975 help="Minimum severity level to report.",
976)
977@click.option(
978 "--ai", "ai_scan", is_flag=True, default=False,
979 help="Enable specialized scanning for AI/LLM vulnerabilities.",
980)
981@click.option(
982 "-c", "--config", "config_path",
983 type=click.Path(exists=True, path_type=Path),
984 help="Path to a pyspector.toml config file.",
985)
986@click.option(
987 "--debounce", default=1.0, show_default=True, metavar="SECONDS",
988 help="Wait this many seconds after the last change before re-scanning.",
989)
990@click.option(
991 "--debug", is_flag=True, default=False,
992 help="Show verbose progress output.",
993)
994@click.option(
995 "--msg", "show_msg", type=bool, default=None,
996 help="Enable or disable the rotating contact message shown below the "
997 "banner (--msg=True / --msg=False). The setting persists across "
998 "future runs until changed again, so it only needs to be set once.",
999)
1000def watch_command(
1001 path: Path,
1002 severity_level: str,
1003 ai_scan: bool,
1004 config_path: Optional[Path],
1005 debounce: float,
1006 debug: bool,
1007 show_msg: Optional[bool],
1008) -> None:
1009 """Continuous watch mode: re-scan on every .py file change."""
1010 try:
1011 from watchdog.observers import Observer
1012 from watchdog.events import FileSystemEventHandler
1013 except ImportError:
1014 click.echo(
1015 "Error: 'watchdog' is required for watch mode.\n"
1016 "Install it with: pip install 'watchdog>=3.0'"
1017 )
1018 sys.exit(1)
1019
1020 _print_banner()
1021 handle_msg_flag(show_msg)
1022 click.echo(f"[*] Watch mode — " + click.style(str(path), bold=True))
1023 click.echo(
1024 f" Severity : {severity_level}"
1025 f" | AI rules : {'on' if ai_scan else 'off'}"
1026 f" | Debounce : {debounce}s"
1027 f" | Ctrl+C to stop\n"
1028 )
1029
1030 _DIVIDER = "─" * 62

Callers

nothing calls this directly

Calls 9

_print_bannerFunction · 0.85
get_cacheFunction · 0.85
_scan_to_issuesFunction · 0.85
ReporterClass · 0.85
_PyHandlerClass · 0.85
get_fingerprintMethod · 0.80
generateMethod · 0.80
startMethod · 0.80
stopMethod · 0.80

Tested by

no test coverage detected