Skip to content

[codex] Default bare plinks invocation to manage#5

Merged
adambuchweitz merged 2 commits into
mainfrom
codex/default-manage-command
Apr 13, 2026
Merged

[codex] Default bare plinks invocation to manage#5
adambuchweitz merged 2 commits into
mainfrom
codex/default-manage-command

Conversation

@adambuchweitz

@adambuchweitz adambuchweitz commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • default bare plinks invocations to the interactive manage flow
  • keep explicit subcommands unchanged and add a CLI regression test for the no-args parse path

Why

Running plinks with no arguments previously failed during clap parsing because a subcommand was required. For a CLI/TUI entrypoint, the expected behavior is to open the interactive manager when no explicit command is provided.

Impact

Users can now launch the TUI with either plinks or plinks manage, while scripted subcommand usage continues to behave the same.

Validation

  • cargo test

Summary by CodeRabbit

  • New Features

    • CLI now defaults to the interactive manager when no subcommand is given; help text, argument names, and examples have been enhanced.
  • Documentation

    • Added Build section; clarified install/run commands, primary-name usage, development/test flow, and Arch packaging steps.
  • Tests

    • Added integration tests for top-level and subcommand help output and for default invocation parsing.

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

CLI now allows no subcommand (defaults to interactive Manage). Clap metadata and help text expanded for commands and args. run() dispatch uses an unwrap-or default to Manage. Tests added for help output and default parsing. README updated with build/install/development/packaging instructions.

Changes

Cohort / File(s) Summary
CLI
src/cli.rs
Made Cli.command an Option<Command>; added about/long_about/after_help text for the top-level and per-variant about strings; added value_name, help, and after_help examples for OpenArgs, ListArgs, AddArgs, RemoveArgs; preserved arg-group constraints and boolean force.
Run / Dispatch
src/lib.rs
Changed dispatch to cli.command.unwrap_or(Command::Manage) so missing subcommand deterministically runs the Manage (TUI) branch and resolves config before calling tui::run.
Tests
tests/cli.rs
Added help_output helper and integration tests asserting top-level and subcommand help contents; added parsing test verifying Cli::parse_from(["plinks"]) yields command == None.
Docs
README.md
Added Build section with dev/release compile instructions and install/run examples; clarified add primary-name semantics; split Development into test + hooks + linters; adjusted Arch packaging steps and makepkg flags and documented ./scripts/build-arch-package.sh behavior.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as "CLI Parser\n(src/cli.rs)"
    participant Runner as "run()\n(src/lib.rs)"
    participant TUI as "tui::run()\n(src/tui)"
    User->>CLI: invoke binary (with or without args)
    CLI-->>Runner: returns Cli { command: Option<Command> }
    Runner->>Runner: command = cli.command.unwrap_or(Command::Manage)
    alt command == Manage
        Runner->>Runner: resolve_config_path(cwd)?
        Runner->>TUI: call tui::run(resolved, opener)
        TUI-->>User: start interactive TUI
    else other command
        Runner->>Runner: dispatch to matching command handler
        Runner-->>User: perform requested action (add/open/list/remove)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[codex] Default bare plinks invocation to manage' directly and clearly describes the main objective: making bare plinks invocation default to the manage command, which is the primary change across src/cli.rs, src/lib.rs, and tests/cli.rs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/default-manage-command

Comment @coderabbitai help to get the list of available commands and usage tips.

@adambuchweitz
adambuchweitz force-pushed the codex/default-manage-command branch 2 times, most recently from 195134f to b8be804 Compare April 13, 2026 14:28
@adambuchweitz
adambuchweitz marked this pull request as ready for review April 13, 2026 16:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/cli.rs (1)

57-58: Improve failure diagnostics in help_output.

If the subprocess fails, include stderr in the assertion message to make CI failures actionable.

Suggested tweak
-    assert!(output.status.success());
+    assert!(
+        output.status.success(),
+        "plinks help command failed: {}",
+        String::from_utf8_lossy(&output.stderr)
+    );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/cli.rs` around lines 57 - 58, The test helper help_output should
include the subprocess stderr when asserting success: update the assertion that
currently uses output.status.success() to include the stderr (e.g.
String::from_utf8_lossy(&output.stderr)) in the assertion message so CI failures
show actionable error output; keep returning the stdout as
String::from_utf8(output.stdout).unwrap() after the improved assert.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/cli.rs`:
- Around line 57-58: The test helper help_output should include the subprocess
stderr when asserting success: update the assertion that currently uses
output.status.success() to include the stderr (e.g.
String::from_utf8_lossy(&output.stderr)) in the assertion message so CI failures
show actionable error output; keep returning the stdout as
String::from_utf8(output.stdout).unwrap() after the improved assert.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d544cc7-7b93-4ec0-be59-6c3bf9a3bb15

📥 Commits

Reviewing files that changed from the base of the PR and between eb76c4e and b8be804.

📒 Files selected for processing (3)
  • src/cli.rs
  • src/lib.rs
  • tests/cli.rs

@adambuchweitz
adambuchweitz force-pushed the codex/default-manage-command branch from b8be804 to af8382f Compare April 13, 2026 17:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/cli.rs (2)

51-59: Improve assertion diagnostics in help_output.

When subprocess help fails, the current assert loses stderr context, making triage slower.

Diff suggestion
 fn help_output(args: &[&str]) -> String {
     let output = ProcessCommand::new(env!("CARGO_BIN_EXE_plinks"))
         .args(args)
         .output()
         .unwrap();
 
-    assert!(output.status.success());
-    String::from_utf8(output.stdout).unwrap()
+    assert!(
+        output.status.success(),
+        "help command failed: {}",
+        String::from_utf8_lossy(&output.stderr)
+    );
+    String::from_utf8(output.stdout).expect("help output must be valid UTF-8")
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/cli.rs` around lines 51 - 59, The assert in help_output loses stderr
when the subprocess fails; change the success check in the help_output function
to include stdout/stderr in the failure message (e.g., replace
assert!(output.status.success()) with an assertion or panic that formats
output.status, String::from_utf8_lossy(&output.stdout) and
String::from_utf8_lossy(&output.stderr) so test failures show both stdout and
stderr for triage).

314-318: Remove exact spacing from help text assertions to prevent brittleness.

Lines 314–318 check help output with spacing-dependent patterns (e.g., "open Open..."). These can fail after clap version updates or formatter changes even when functionality is unchanged. Refactor to check only the descriptions:

Suggested refactor
-    assert!(help.contains("open    Open a saved link by primary name, alias, or tag"));
-    assert!(help.contains("list    List saved links"));
-    assert!(help.contains("add     Add a saved link"));
-    assert!(help.contains("remove  Remove a saved link by primary name"));
-    assert!(help.contains("manage  Open the interactive terminal UI"));
+    assert!(help.contains("Open a saved link by primary name, alias, or tag"));
+    assert!(help.contains("List saved links"));
+    assert!(help.contains("Add a saved link"));
+    assert!(help.contains("Remove a saved link by primary name"));
+    assert!(help.contains("Open the interactive terminal UI"));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/cli.rs` around lines 314 - 318, The help output assertions currently
depend on exact spacing (e.g., assert!(help.contains("open    Open a saved
link..."))); change them to avoid brittle spacing by asserting the command name
and its description exist separately in the help string (use the existing help
variable). For each case (open, list, add, remove, manage) replace the
spacing-dependent assertion with a pair or single assertion that checks
help.contains("open") and help.contains("Open a saved link"), and likewise for
"list"/"List saved links", "add"/"Add a saved link", "remove"/"Remove a saved
link by primary name", and "manage"/"Open the interactive terminal UI" so
formatting changes won't break the tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/cli.rs`:
- Around line 51-59: The assert in help_output loses stderr when the subprocess
fails; change the success check in the help_output function to include
stdout/stderr in the failure message (e.g., replace
assert!(output.status.success()) with an assertion or panic that formats
output.status, String::from_utf8_lossy(&output.stdout) and
String::from_utf8_lossy(&output.stderr) so test failures show both stdout and
stderr for triage).
- Around line 314-318: The help output assertions currently depend on exact
spacing (e.g., assert!(help.contains("open    Open a saved link..."))); change
them to avoid brittle spacing by asserting the command name and its description
exist separately in the help string (use the existing help variable). For each
case (open, list, add, remove, manage) replace the spacing-dependent assertion
with a pair or single assertion that checks help.contains("open") and
help.contains("Open a saved link"), and likewise for "list"/"List saved links",
"add"/"Add a saved link", "remove"/"Remove a saved link by primary name", and
"manage"/"Open the interactive terminal UI" so formatting changes won't break
the tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e9d0159-54d6-41a3-89bb-355419991cd1

📥 Commits

Reviewing files that changed from the base of the PR and between b8be804 and af8382f.

📒 Files selected for processing (4)
  • README.md
  • src/cli.rs
  • src/lib.rs
  • tests/cli.rs
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib.rs

@adambuchweitz
adambuchweitz force-pushed the codex/default-manage-command branch 2 times, most recently from 3528bde to d6aa40b Compare April 13, 2026 18:27
@adambuchweitz
adambuchweitz force-pushed the codex/default-manage-command branch from d6aa40b to 4bf6520 Compare April 13, 2026 18:44
@adambuchweitz

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/cli.rs (1)

343-397: Consider a tiny helper to reduce repeated help-assert boilerplate.

The repeated contains + identical error message pattern is readable but a bit verbose; a local helper would keep future help tests easier to extend.

♻️ Optional refactor
+fn assert_help_contains(help: &str, expected: &str, context: &str) {
+    assert!(
+        help.contains(expected),
+        "unexpected {context} help output (missing: {expected}):\n{help}"
+    );
+}
-    assert!(
-        help.contains("Add a saved link"),
-        "unexpected add help output:\n{help}"
-    );
+    assert_help_contains(&help, "Add a saved link", "add");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/cli.rs` around lines 343 - 397, Add a small local test helper to remove
repeated assert!(help.contains(...), "unexpected ...\n{help}") boilerplate:
create e.g. assert_help_contains(help: &str, expected: &str, label: &str) that
calls assert!(help.contains(expected), "unexpected {label} help
output:\n{help}"), then replace the repeated assertions in the add-help checks
and the test open_help_explains_name_alias_and_tag_modes (which calls
help_output) with calls to assert_help_contains(help, "...", "add" or "open") to
make the tests shorter and clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/cli.rs`:
- Around line 343-397: Add a small local test helper to remove repeated
assert!(help.contains(...), "unexpected ...\n{help}") boilerplate: create e.g.
assert_help_contains(help: &str, expected: &str, label: &str) that calls
assert!(help.contains(expected), "unexpected {label} help output:\n{help}"),
then replace the repeated assertions in the add-help checks and the test
open_help_explains_name_alias_and_tag_modes (which calls help_output) with calls
to assert_help_contains(help, "...", "add" or "open") to make the tests shorter
and clearer.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83c9b3ea-ba08-4c92-a037-066de870b9e2

📥 Commits

Reviewing files that changed from the base of the PR and between d6aa40b and 4bf6520.

📒 Files selected for processing (4)
  • README.md
  • src/cli.rs
  • src/lib.rs
  • tests/cli.rs
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib.rs

@adambuchweitz
adambuchweitz merged commit ce3c408 into main Apr 13, 2026
5 checks passed
@adambuchweitz
adambuchweitz deleted the codex/default-manage-command branch April 13, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant