Files
config-man/examples/basic_usage.py

49 lines
1.1 KiB
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.
#!/usr/bin/env python3
"""
Config-Man 基本使用示例
演示如何使用 Config-Man CLI 工具的基本功能。
"""
import sys
import os
# 添加项目根目录到路径
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config_man.core import ViewCommand
from config_man.utils import patch_rclone
def main():
"""基本使用示例"""
print("Config-Man 基本使用示例")
print("=" * 50)
# 启用模拟环境
patch_rclone()
# 创建查看命令处理器
view_cmd = ViewCommand()
# 查看版本 0.30 的配置
print("\n1. 查看版本 0.30 的配置:")
success = view_cmd.execute("0.30", json_format=False)
if success:
print("✅ 查看成功")
else:
print("❌ 查看失败")
# 查看版本 0.29 的配置JSON格式
print("\n2. 查看版本 0.29 的配置JSON格式:")
success = view_cmd.execute("0.29", json_format=True)
if success:
print("✅ 查看成功")
else:
print("❌ 查看失败")
if __name__ == "__main__":
main()