cli.rs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. use clap::{Parser, Subcommand};
  2. #[derive(Parser)]
  3. #[command(author, version, about = "DGX Spark Launcher для vLLM и SGLang")]
  4. pub struct Cli {
  5. #[arg(long, short, default_value = "config.toml")]
  6. pub config: String,
  7. #[arg(long, short, help = "Показать команды без выполнения")]
  8. pub dry_run: bool,
  9. #[command(subcommand)]
  10. pub command: Commands,
  11. }
  12. #[derive(Subcommand)]
  13. pub enum Commands {
  14. /// Запустить кластер
  15. Serve {
  16. #[arg(long, required = true)]
  17. recipe: String,
  18. #[arg(long, default_value = "auto")]
  19. cluster: String,
  20. },
  21. /// Показать логи контейнеров
  22. Logs {
  23. #[arg(long, required = true)]
  24. recipe: String,
  25. #[arg(long, action = clap::ArgAction::SetTrue)]
  26. follow: bool,
  27. },
  28. /// Остановить кластер
  29. Stop {
  30. #[arg(long, required = true)]
  31. recipe: String,
  32. },
  33. /// Проверить здоровье кластера
  34. Health {
  35. #[arg(
  36. long,
  37. help = "Имя кластера (например, 4nodes-switch). Если не указано - проверяет все."
  38. )]
  39. cluster: Option<String>,
  40. #[arg(
  41. long,
  42. help = "Показать хост-ключи узлов (для добавления в config.toml)"
  43. )]
  44. fingerprint: bool,
  45. },
  46. /// Проверить и исправить рецепт (doctor mode)
  47. Doctor {
  48. #[arg(long, required = true, help = "Имя рецепта для проверки")]
  49. recipe: String,
  50. #[arg(
  51. long,
  52. default_value = "auto",
  53. help = "Кластер (если не auto — использует recipe.cluster)"
  54. )]
  55. cluster: String,
  56. #[arg(
  57. long,
  58. help = "Автоматически исправить проблемы (создать Dockerfile + собрать образ)"
  59. )]
  60. repair: bool,
  61. },
  62. /// Управление tmux-сессиями (альтернатива Docker)
  63. #[command(subcommand)]
  64. Tmux(TmuxCommands),
  65. }
  66. #[derive(Subcommand)]
  67. pub enum TmuxCommands {
  68. /// Запустить кластер через tmux
  69. Serve {
  70. #[arg(long, required = true)]
  71. recipe: String,
  72. #[arg(long, default_value = "auto")]
  73. cluster: String,
  74. },
  75. /// Остановить tmux-сессии
  76. Stop {
  77. #[arg(long, required = true)]
  78. recipe: String,
  79. #[arg(long, default_value = "auto")]
  80. cluster: String,
  81. },
  82. /// Статус tmux-сессий (подробный)
  83. Status {
  84. #[arg(long, required = true)]
  85. recipe: String,
  86. #[arg(long, default_value = "auto")]
  87. cluster: String,
  88. },
  89. /// Показать логи tmux-сессий
  90. Logs {
  91. #[arg(long, required = true)]
  92. recipe: String,
  93. #[arg(long, action = clap::ArgAction::SetTrue)]
  94. follow: bool,
  95. #[arg(long, default_value = "auto")]
  96. cluster: String,
  97. },
  98. /// Подключиться к tmux-сессии головного узла
  99. Attach {
  100. #[arg(long, required = true)]
  101. recipe: String,
  102. #[arg(long, default_value = "auto")]
  103. cluster: String,
  104. },
  105. }