Skip to content

Commit b785cab

Browse files
committed
refactor: help the user find a transform
1 parent 8254c36 commit b785cab

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

c2rust-refactor/src/command.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,14 @@ impl RefactorState {
572572
s
573573
}));
574574

575-
let mut cmd = self.cmd_reg.get_command(cmd_name, &args)?;
575+
let mut cmd = self.cmd_reg.get_command(cmd_name, &args).map_err(|mut e| {
576+
e.push_str("\nValid commands:");
577+
for c in self.cmd_reg.commands.keys() {
578+
e.push_str("\n\t");
579+
e.push_str(c);
580+
}
581+
e
582+
})?;
576583
profile_start!(format!("Command {}", cmd_name));
577584
cmd.run(self);
578585
profile_end!(format!("Command {}", cmd_name));

c2rust-refactor/src/interact/main_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl InteractState {
194194
match self.state.run(&name, &args) {
195195
Ok(_) => {}
196196
Err(e) => {
197-
eprintln!("{:?}", e);
197+
eprintln!("{e}");
198198
panic!("Invalid command.");
199199
}
200200
}

c2rust-refactor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ fn main_impl(opts: Options) -> interface::Result<()> {
487487
match state.run(&cmd.name, &cmd.args) {
488488
Ok(_) => {}
489489
Err(e) => {
490-
eprintln!("{:?}", e);
490+
eprintln!("{e}");
491491
std::process::exit(1);
492492
}
493493
}

0 commit comments

Comments
 (0)