aboutsummaryrefslogtreecommitdiff
path: root/examples/example-repl-basic/src/main.rs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-31 02:42:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-31 17:19:20 +0800
commit2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch)
treef10b89007fc67ca1a948f34abe6869b49296b932 /examples/example-repl-basic/src/main.rs
parent3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff)
Enhance code quality across the entire codebase
Diffstat (limited to 'examples/example-repl-basic/src/main.rs')
-rw-r--r--examples/example-repl-basic/src/main.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/example-repl-basic/src/main.rs b/examples/example-repl-basic/src/main.rs
index 630c419..d44c92a 100644
--- a/examples/example-repl-basic/src/main.rs
+++ b/examples/example-repl-basic/src/main.rs
@@ -66,7 +66,7 @@ fn main() {
// Add hooks to handle REPL-related events
program.with_hook(ProgramHook::empty().on_repl_begin(|| {
// Print welcome message
- println!("Welcome!")
+ println!("Welcome!");
}));
// Start the REPL loop
@@ -118,11 +118,11 @@ fn handle_ls(_prev: EntryLs, current_dir: &ResCurrentDir) -> Next {
let dir = &current_dir.dir;
let entries: Vec<String> = std::fs::read_dir(dir)
.into_iter()
- .flat_map(|rd| rd.filter_map(|e| e.ok()))
+ .flat_map(|rd| rd.filter_map(std::result::Result::ok))
.map(|e| {
let name = e.file_name().to_string_lossy().to_string();
if e.file_type().map(|t| t.is_dir()).unwrap_or(false) {
- format!("{}/", name)
+ format!("{name}/")
} else {
name
}
@@ -133,11 +133,11 @@ fn handle_ls(_prev: EntryLs, current_dir: &ResCurrentDir) -> Next {
ResultList::new(entries).to_render()
}
-// Render ResultList data
+/// Render ResultList data
#[renderer]
fn render_list(list: ResultList) {
for item in list.inner {
- r_println!("{}", item)
+ r_println!("{}", item);
}
}
@@ -151,20 +151,21 @@ fn handle_exit(
repl.exit = true;
}
-// Handle clear command event
+/// Handle clear command event
#[chain]
fn handle_clear(_prev: EntryClear) {
// Clear the terminal screen
print!("\x1B[2J\x1B[1;1H");
}
-// Handle path not found event
+/// Handle path not found event
#[renderer]
fn render_error_directory_not_exist(err: ErrorDirectoryNotExist) {
r_println!("Directory not found: {}", err.inner.display())
}
-// Handle dispatcher not found event
+/// Handle dispatcher not found event
+/// Renders the error when a command is not found.
#[renderer]
fn dispatcher_not_found(prev: ErrorDispatcherNotFound) {
r_println!("Command not found: \"{}\"", prev.join(", "))