feat: auth

This commit is contained in:
2026-04-15 14:05:33 +08:00
parent 321c550a66
commit 6f263e365f
15 changed files with 833 additions and 17 deletions

View File

@@ -0,0 +1,53 @@
import argparse
import asyncio
import json
from .load_plan_tools import (
get_transport_vehicle_by_license_plate,
list_unshipped_shipments,
)
def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Standalone CLI for load-plan API tools")
subparsers = parser.add_subparsers(dest="command", required=True)
vehicle_parser = subparsers.add_parser("vehicle", help="Fetch a vehicle by license plate")
vehicle_parser.add_argument("--merchant-id", type=int, required=True)
vehicle_parser.add_argument("--license-plate", required=True)
shipments_parser = subparsers.add_parser("shipments", help="List unshipped shipments by area")
shipments_parser.add_argument("--merchant-id", type=int, required=True)
shipments_parser.add_argument("--area", required=True)
shipments_parser.add_argument("--limit", type=int)
shipments_parser.add_argument("--offset", type=int)
return parser
async def _run() -> None:
parser = _build_parser()
args = parser.parse_args()
if args.command == "vehicle":
result = await get_transport_vehicle_by_license_plate(
merchant_id=args.merchant_id,
license_plate=args.license_plate,
)
else:
result = await list_unshipped_shipments(
merchant_id=args.merchant_id,
area=args.area,
limit=args.limit,
offset=args.offset,
)
print(json.dumps(result.model_dump(mode="json"), ensure_ascii=False, indent=2))
def main() -> None:
asyncio.run(_run())
if __name__ == "__main__":
main()