def Parser() -> argparse.ArgumentParser:
"""Build an offline help surface and bounded command options."""
parser = DiagnosticArgumentParser(prog="python -m flayer", description="F-Layer diagnostics and owned lifecycle")
commands = parser.add_subparsers(dest="command", required=True)
for command in ("status", "check", "health", "benchmark"):
child = commands.add_parser(command)
child.add_argument("--format", choices=("text", "json"), default="text")
if command in ("health", "benchmark"):
child.add_argument("--endpoint", help="Explicit HTTP(S) endpoint without credentials")
child.add_argument("--timeout", type=float, default=3.0, metavar="SECONDS")
if command == "benchmark":
child.add_argument("--count", type=int, default=3)
child.add_argument("--bytes", type=int, default=64 * 1024, dest="byte_limit")
lifecycle = commands.add_parser("lifecycle", help="Explicit owned stack lifecycle")
actions = lifecycle.add_subparsers(dest="action", required=True)
for action in ("create", "status", "destroy", "recover"):
child = actions.add_parser(action)
child.add_argument("--config", required=True, help="Explicit lifecycle plan TOML path")
child.add_argument("--state", required=True, help="Explicit owned snapshot path")
child.add_argument("--yc-profile", required=True, help="Explicit preauthenticated yc profile")
child.add_argument("--format", choices=("text", "json"), default="text")
if action != "status":
child.add_argument("--allow-mutation", action="store_true")
child.add_argument("--scope-confirm", required=True, help="Repeat the exact folder ID")
if action == "recover":
child.add_argument("--rollback", action="store_true")
project = commands.add_parser("project", help="Create a private installable VPN project")
project_actions = project.add_subparsers(dest="action", required=True)
initialize = project_actions.add_parser("init", help="Create an editable project and administration key")
initialize.add_argument("directory")
vpn = commands.add_parser("vpn", help="Prepare and manage a two-protocol VPN project")
vpn_actions = vpn.add_subparsers(dest="action", required=True)
for action in ("prepare", "deploy", "status", "destroy", "recover"):
child = vpn_actions.add_parser(action)
child.add_argument("--project", required=True, help="Private project directory")
child.add_argument("--format", choices=("text", "json"), default="text")
if action in {"deploy", "destroy", "recover"}:
child.add_argument("--allow-mutation", action="store_true")
child.add_argument("--scope-confirm", required=True, help="Repeat the exact cloud folder ID")
if action == "recover":
child.add_argument("--rollback", action="store_true")
export = vpn_actions.add_parser("export", help="Export existing device files without cloud access")
export.add_argument("--project", required=True, help="Private project directory")
export.add_argument("--device", required=True, help="One declared device ID")
export.add_argument("--protocol", required=True, choices=("amneziawg", "vless-reality"))
export.add_argument("--output", required=True, help="Separate private export root")
export.add_argument("--qr", action="store_true", help="Include numbered native AmneziaVPN QR SVGs")
export.add_argument("--format", choices=("text", "json"), default="text")
return parser