Skip to content

Commit bc5c113

Browse files
committed
fix(repl-logic): man command now shows man when no payload or man and show man {payload} if payload
1 parent c1b951a commit bc5c113

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

crates/pluginlab/tests/e2e_test.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,32 @@ mod e2e_test {
471471
.exp_string("man - Show the manual for a command")
472472
.expect("Didn't get expected manual output");
473473
}
474+
475+
#[test]
476+
fn test_man_echo() {
477+
let project_root = find_project_root();
478+
println!("Setting current directory to: {:?}", project_root);
479+
std::env::set_current_dir(&project_root).unwrap();
480+
let mut session = spawn(
481+
&build_command(&["plugin_echo.wasm"], "repl_logic_guest.wasm"),
482+
Some(TEST_TIMEOUT),
483+
)
484+
.expect("Can't launch pluginlab with plugin greet");
485+
486+
session
487+
.exp_string("[Host] Starting REPL host...")
488+
.expect("Didn't see startup message");
489+
session
490+
.exp_string("[Host] Loading plugin:")
491+
.expect("Didn't see plugin loading message");
492+
session
493+
.exp_string("repl(0)>")
494+
.expect("Didn't see REPL prompt");
495+
session
496+
.send_line("man echo")
497+
.expect("Failed to send command");
498+
session
499+
.exp_string("echo - Echo a message (built with Rust")
500+
.expect("Didn't get expected manual output");
501+
}
474502
}

crates/repl-logic-guest/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ impl ReplLogicGuest for Component {
2323
if let Some(response) = reserved::run(&parsed_line.command, &parsed_line.payload) {
2424
return transport::ReadlineResponse::Ready(response);
2525
}
26-
if let Some(response) = reserved::man(&parsed_line.command) {
27-
return transport::ReadlineResponse::Ready(response);
26+
27+
if parsed_line.command == "man"
28+
&& (parsed_line.payload.is_empty() || parsed_line.payload == "man")
29+
{
30+
if let Some(response) = reserved::man(&parsed_line.command) {
31+
return transport::ReadlineResponse::Ready(response);
32+
}
2833
}
2934

3035
// if no reserved command was run return the parsed line to be passed to the plugin to run from the host

packages/web-host/tests/repl-logic.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,10 @@ test("man", async ({ page }) => {
9292
const stdout2 = await getLastStd(page, "stdout");
9393
await expect(stdout2).toContainText("man - Show the manual for a command");
9494
});
95+
96+
test("man echo", async ({ page }) => {
97+
await page.goto("/#repl");
98+
await fillAndSubmitCommand(page, "man echo");
99+
const stdout = await getLastStd(page, "stdout");
100+
await expect(stdout).toContainText("echo - Echo a message (built with Rust");
101+
});

0 commit comments

Comments
 (0)