cli.rs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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(long, help = "Показать хост-ключи узлов (для добавления в config.toml)")]
  41. fingerprint: bool,
  42. },
  43. /// Проверить и исправить рецепт (doctor mode)
  44. Doctor {
  45. #[arg(long, required = true, help = "Имя рецепта для проверки")]
  46. recipe: String,
  47. #[arg(long, default_value = "auto", help = "Кластер (если не auto — использует recipe.cluster)")]
  48. cluster: String,
  49. #[arg(long, help = "Автоматически исправить проблемы (создать Dockerfile + собрать образ)")]
  50. repair: bool,
  51. },
  52. /// Управление tmux-сессиями (альтернатива Docker)
  53. #[command(subcommand)]
  54. Tmux(TmuxCommands),
  55. }
  56. #[derive(Subcommand)]
  57. pub enum TmuxCommands {
  58. /// Запустить кластер через tmux
  59. Serve {
  60. #[arg(long, required = true)]
  61. recipe: String,
  62. #[arg(long, default_value = "auto")]
  63. cluster: String,
  64. },
  65. /// Остановить tmux-сессии
  66. Stop {
  67. #[arg(long, required = true)]
  68. recipe: String,
  69. #[arg(long, default_value = "auto")]
  70. cluster: String,
  71. },
  72. /// Статус tmux-сессий (подробный)
  73. Status {
  74. #[arg(long, required = true)]
  75. recipe: String,
  76. #[arg(long, default_value = "auto")]
  77. cluster: String,
  78. },
  79. /// Показать логи tmux-сессий
  80. Logs {
  81. #[arg(long, required = true)]
  82. recipe: String,
  83. #[arg(long, action = clap::ArgAction::SetTrue)]
  84. follow: bool,
  85. #[arg(long, default_value = "auto")]
  86. cluster: String,
  87. },
  88. /// Подключиться к tmux-сессии головного узла
  89. Attach {
  90. #[arg(long, required = true)]
  91. recipe: String,
  92. #[arg(long, default_value = "auto")]
  93. cluster: String,
  94. },
  95. }