Skip to content

Commit 6a65211

Browse files
committed
Code clean up
1 parent 97290aa commit 6a65211

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## keepc
1+
## What is keepc?
22
Keep Command or Keepc is a meta cli program designed to keep important commands that are difficult to remember. Keepc is coded in The Rust Programming Language.
33

44
## How to install
@@ -34,6 +34,8 @@ Create a pull request.
3434
## TODO
3535
Add other ways to run existing commands. For example, list/ls, new/add, run/execute....
3636

37+
Make rm and run commands search in descriptions.
38+
3739
## License
3840
Distributed under the [GPL-3.0 License](LICENSE).
3941

src/main.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,9 @@ fn delete_command(command: String) -> Result<()> {
184184
.filter(|cmd| cmd.to_lowercase().contains(&pattern))
185185
.cloned()
186186
.collect();
187-
match matching_commands.len() {
188-
0 => {
189-
println!("No commands found matching '{}'", command);
190-
},
191-
_ => {
187+
if matching_commands.is_empty() {
188+
println!("No commands found matching '{}'", command);
189+
} else {
192190
println!("Found {} matching commands:", matching_commands.len());
193191
for (i, cmd) in matching_commands.iter().enumerate() {
194192
println!("[{}] \x1b[34m{}\x1b[0m: {}",
@@ -213,7 +211,6 @@ fn delete_command(command: String) -> Result<()> {
213211
}
214212
};
215213
}
216-
}
217214
Ok(())
218215
}
219216

@@ -267,11 +264,9 @@ fn execute_command(command: String) -> Result<()> {
267264
.filter(|cmd| cmd.to_lowercase().contains(&pattern))
268265
.cloned()
269266
.collect();
270-
match matching_commands.len() {
271-
0 => {
272-
println!("No commands found matching '{}'", command);
273-
},
274-
_ => {
267+
if matching_commands.is_empty() {
268+
println!("No commands found matching '{}'", command);
269+
} else {
275270
println!("Found {} matching commands:", matching_commands.len());
276271
for (i, cmd) in matching_commands.iter().enumerate() {
277272
println!("[{}] \x1b[34m{}\x1b[0m: {}",
@@ -307,13 +302,11 @@ fn execute_command(command: String) -> Result<()> {
307302
}
308303
};
309304
}
310-
}
311305
Ok(())
312306
}
313307

314308
fn main() -> Result<()> {
315309
let cli = Cli::parse();
316-
317310
match cli.command {
318311
Some(Commands::New { command, description }) => new_command(command, description),
319312
Some(Commands::List) => list_commands(),

0 commit comments

Comments
 (0)