Преглед изворни кода

feat: serve follows logs by default, returns Cluster for follow-up

- serve() now returns Result<Cluster> (the resolved/created cluster),
  letting the caller use it for follow-up operations
- Follow-up logs --follow moved to caller (main.rs), keeping serve at
  7 params (clippy limit)
- Added AGENTS.md rule: solve clippy warnings by refactoring, not
  #[allow(...)]
Alexander Korolev пре 4 месеци
родитељ
комит
ce60c5c59f
3 измењених фајлова са 8 додато и 10 уклоњено
  1. 1 0
      AGENTS.md
  2. 2 8
      src/docker/mod.rs
  3. 5 2
      src/main.rs

+ 1 - 0
AGENTS.md

@@ -100,3 +100,4 @@ commands = ["cmd", { command = "cmd", on_failure = "warn" }]
 
 - Files ≤500 lines (`make check-lines`)
 - `#![deny(clippy::wildcard_imports)]` — no `use foo::*;`
+- **Clippy warnings**: solve by refactoring the code (extract structs, reduce arg count, restructure logic). Do **not** add `#[allow(...)]` attributes. If the only viable fix is an allow attribute, consult the user for guidance.

+ 2 - 8
src/docker/mod.rs

@@ -12,7 +12,6 @@ use crate::{
     ssh::{run_ssh, run_ssh_follow, run_ssh_with_retry},
 };
 
-#[allow(clippy::too_many_arguments)]
 pub async fn serve(
     config: &Config,
     recipe_name: &str,
@@ -20,9 +19,8 @@ pub async fn serve(
     node_name: Option<&str>,
     keep: bool,
     skip_before_serve: bool,
-    follow: bool,
     dry_run: bool,
-) -> Result<()> {
+) -> Result<Cluster> {
     let recipe = load_recipe(recipe_name).await?;
     let rn = recipe.name.clone();
     let re = recipe.engine.clone();
@@ -93,11 +91,7 @@ pub async fn serve(
         dry_run,
     )
     .await?;
-    if !dry_run && follow {
-        info!("{}", fluent_i18n::t!("container-log-header"));
-        show_logs(config, &cluster, recipe_name, true, dry_run).await?;
-    }
-    Ok(())
+    Ok(cluster)
 }
 pub(crate) fn logs_tail_cmd(recipe_name: &str, rank: u32, tail: usize) -> String {
     format!(

+ 5 - 2
src/main.rs

@@ -85,17 +85,20 @@ async fn main() -> Result<()> {
             skip_before_serve,
             follow,
         } => {
-            docker::serve(
+            let cluster = docker::serve(
                 &config,
                 &recipe,
                 &cluster,
                 node.as_deref(),
                 keep,
                 skip_before_serve,
-                follow,
                 dry_run,
             )
             .await?;
+            if follow && !dry_run {
+                tracing::info!("{}", fluent_i18n::t!("container-log-header"));
+                docker::show_logs(&config, &cluster, &recipe, true, dry_run).await?;
+            }
         }
         Commands::Logs {
             recipe: recipe_name,