Skip to content

Commit 0a8b8fd

Browse files
committed
fix(review): address PR #910 review feedback
- container.rs: warn on kubectl JSON parse failure instead of silent fallback - runner.rs: fix savings inflation when filter_stdout_only by tracking stdout only - README.md: document automod behavior in module registration step
1 parent f3217a4 commit 0a8b8fd

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/cmds/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Adding a new filter or command requires changes in multiple places. For TOML-vs-
189189
- Add `.tee("label")` when the filter parses structured output (enables raw output recovery on failure)
190190
- **Exit codes**: handled automatically by `run_filtered()` — just return its result
191191
2. **Register module**:
192-
- Add `pub mod mycmd_cmd;` to the ecosystem's `mod.rs`
192+
- Ecosystem `mod.rs` files use `automod::dir!()` — any `.rs` file in the directory becomes a public module automatically. No manual `pub mod` needed, but be aware: WIP or helper files will also be exposed. Only commit command-ready modules.
193193
- Add variant to `Commands` enum in `main.rs` with `#[arg(trailing_var_arg = true, allow_hyphen_values = true)]`
194194
- Add routing match arm in `main.rs`: `Commands::Mycmd { args } => mycmd_cmd::run(&args, cli.verbose)?,`
195195
3. **Add rewrite pattern** — Entry in `src/discover/rules.rs` (PATTERNS + RULES arrays at matching index) so hooks auto-rewrite the command

src/cmds/cloud/container.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ where
3939
label,
4040
|stdout| match serde_json::from_str::<Value>(stdout) {
4141
Ok(json) => filter_fn(&json),
42-
Err(_) => stdout.to_string(),
42+
Err(e) => {
43+
eprintln!("[rtk] kubectl: JSON parse failed: {}", e);
44+
stdout.to_string()
45+
}
4346
},
4447
RunOptions::stdout_only()
4548
.early_exit_on_failure()

src/core/runner.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,15 @@ where
108108
eprintln!("{}", stderr.trim());
109109
}
110110

111+
let raw_for_tracking = if opts.filter_stdout_only {
112+
stdout.as_ref()
113+
} else {
114+
raw.as_str()
115+
};
111116
timer.track(
112117
&format!("{} {}", tool_name, args_display),
113118
&format!("rtk {} {}", tool_name, args_display),
114-
&raw,
119+
raw_for_tracking,
115120
&filtered,
116121
);
117122

0 commit comments

Comments
 (0)