# retoor <retoor@molodetz.nl>

import sys

from client import from_env


def main() -> None:
    if len(sys.argv) < 2:
        print("usage: DEVRANT_USERNAME=.. DEVRANT_PASSWORD=.. python post_rant.py <text> [tags]")
        raise SystemExit(1)
    text = sys.argv[1]
    tags = sys.argv[2] if len(sys.argv) > 2 else ""
    api = from_env()
    api.login()
    result = api.post_rant(text, tags)
    if result.get("success"):
        print(f"posted rant {result['rant_id']}")
    else:
        print(f"failed: {result.get('error')}")


if __name__ == "__main__":
    main()
