Skip to content

feat: Adding sed command to rtk list#1511

Open
Kaue-Romero wants to merge 1 commit intortk-ai:masterfrom
Kaue-Romero:master
Open

feat: Adding sed command to rtk list#1511
Kaue-Romero wants to merge 1 commit intortk-ai:masterfrom
Kaue-Romero:master

Conversation

@Kaue-Romero
Copy link
Copy Markdown

Summary

  • Add rtk sed as a system command that runs native sed unchanged and compacts large stdout.
  • Preserve stderr, exit codes, and token tracking while shortening long sed output with head/tail retention.
  • Document rtk sed in the command list and system command coverage docs.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

Copilot AI review requested due to automatic review settings April 25, 2026 01:44
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pszymkowiak pszymkowiak added effort-medium 1-2 jours, quelques fichiers enhancement New feature or request labels Apr 25, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟢 Risk low

Summary

Adds a new rtk sed system command that runs native sed unchanged and compacts large stdout by preserving head/tail lines and truncating long lines. Includes documentation updates across README, coverage docs, and system command docs, along with unit tests for the compaction logic and CLI argument pass-through.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new rtk sed system command to the CLI, intended to run native sed while compacting large stdout and preserving tracking/exit-code behavior.

Changes:

  • Added a Sed subcommand to the Clap CLI and wired it into run_cli() and is_operational_command().
  • Introduced src/cmds/system/sed_cmd.rs to execute sed and compact stdout via head/tail retention + line truncation (with unit tests).
  • Updated user-facing documentation to list rtk sed and its expected savings behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main.rs Registers rtk sed, dispatches execution, marks it operational, and adds an arg-parsing test.
src/cmds/system/sed_cmd.rs Implements sed execution + stdout compaction and unit tests for the compaction behavior.
src/cmds/system/README.md Documents the new system command module.
docs/guide/resources/what-rtk-covers.md Adds sed to the coverage/savings table.
README.md Adds rtk sed example usage to the command list.

Comment on lines +20 to +25
let mut cmd = resolved_command("sed");
for arg in args {
cmd.arg(arg);
}

let result = exec_capture(&mut cmd)?;
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec_capture forces stdin to Stdio::null(), so rtk sed will not work for common usages like echo foo | rtk sed 's/o/a/g' or rtk sed '...' (reading from stdin). Consider running sed via core::stream::run_streaming with StdinMode::Inherit (and ideally a streaming head/tail filter) so stdin is preserved and you don’t have to buffer unbounded stdout into memory for large outputs.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,144 @@
//! Runs sed and compacts large stdout while preserving native behavior.
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module-level doc comment says sed runs “while preserving native behavior”, but the implementation compacts/truncates stdout and (as written) disables stdin. Please reword to reflect what’s actually preserved (exit code, stderr) vs what changes (stdout compaction / potential stdin behavior).

Suggested change
//! Runs sed and compacts large stdout while preserving native behavior.
//! Runs sed, preserving the underlying exit code and stderr while compacting
//! and truncating large stdout output.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +26
let result = exec_capture(&mut cmd)?;
let filtered_stdout = compact_sed_output(&result.stdout);
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec_capture(&mut cmd)? returns a fairly generic error; please add anyhow::Context here (similar to other command modules) so failures are attributable to sed execution (e.g., missing binary, spawn failure).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-medium 1-2 jours, quelques fichiers enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants