Files
memoscli/main.py

36 lines
1007 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
import os
from src.send import MemosAPI, send_memo
def main():
"""Memos CLI 主函数"""
print("=== Memos CLI ===")
print("一个命令行Memos内容发布工具")
try:
# 测试API连接
api = MemosAPI()
if api.test_connection():
print("[SUCCESS] 成功连接到Memos服务器")
# 发送欢迎消息
result = api.send_memo(
content="欢迎使用Memos CLI",
visibility="PRIVATE",
tags=["欢迎", "CLI"]
)
print(f"[SUCCESS] 欢迎消息已发送Memo ID: {result.get('id')}")
else:
print("[ERROR] 无法连接到Memos服务器")
print("请检查 .env 文件中的配置")
except ValueError as e:
print(f"[ERROR] 配置错误: {e}")
print("请确保已正确配置 .env 文件")
except Exception as e:
print(f"[ERROR] 发生错误: {e}")
if __name__ == "__main__":
main()