mi-task/start.py

105 lines
3.5 KiB
Python
Raw Permalink 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
"""
机器狗控制系统启动脚本
提供多种启动方式的便捷入口
"""
import sys
import os
import argparse
# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from main import main, legacy_main, run_complete_task_mode, run_test_mode, run_interactive_test_mode
def print_usage():
"""打印使用说明"""
print("="*70)
print(" 机器狗控制系统启动脚本")
print("="*70)
print("使用方法:")
print(" python start.py [选项]")
print()
print("选项:")
print(" -h, --help 显示此帮助信息")
print(" -m, --mode MODE 直接启动指定模式")
print(" MODE可以是: task, test, interactive")
print(" -l, --legacy 使用原始模式(直接运行完整任务)")
print(" -i, --interactive 启动交互式菜单(默认)")
print()
print("模式说明:")
print(" task - 完整任务模式运行完整的任务1-5流程")
print(" test - 测试模式:进入子运动函数测试菜单")
print(" interactive - 交互式测试:快速命令行测试界面")
print(" legacy - 原始模式:直接运行完整任务(兼容旧版)")
print()
print("示例:")
print(" python start.py # 启动交互式菜单")
print(" python start.py -m task # 直接运行完整任务")
print(" python start.py -m test # 直接进入测试模式")
print(" python start.py -m interactive # 直接进入交互式测试")
print(" python start.py -l # 使用原始模式")
print("="*70)
def main_cli():
"""命令行主函数"""
parser = argparse.ArgumentParser(
description="机器狗控制系统启动脚本",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
示例:
python start.py # 启动交互式菜单
python start.py -m task # 直接运行完整任务
python start.py -m test # 直接进入测试模式
python start.py -m interactive # 直接进入交互式测试
python start.py -l # 使用原始模式
"""
)
parser.add_argument(
'-m', '--mode',
choices=['task', 'test', 'interactive'],
help='直接启动指定模式'
)
parser.add_argument(
'-l', '--legacy',
action='store_true',
help='使用原始模式(直接运行完整任务)'
)
parser.add_argument(
'-i', '--interactive',
action='store_true',
help='启动交互式菜单(默认)'
)
args = parser.parse_args()
try:
if args.legacy:
print("🔄 启动原始模式...")
legacy_main()
elif args.mode == 'task':
print("🚀 启动完整任务模式...")
run_complete_task_mode()
elif args.mode == 'test':
print("🔧 启动测试模式...")
run_test_mode()
elif args.mode == 'interactive':
print("⚡ 启动交互式测试模式...")
run_interactive_test_mode()
else:
# 默认启动交互式菜单
print("🎯 启动交互式菜单...")
main()
except KeyboardInterrupt:
print("\n👋 程序被用户中断,再见!")
except Exception as e:
print(f"❌ 发生错误: {e}")
sys.exit(1)
if __name__ == "__main__":
main_cli()