Removed warnings
This commit is contained in:
parent
1b57352393
commit
28783a5d1b
@ -4,3 +4,7 @@ Rust Shell. This is an attempt to create a simple shell in Rust, because why not
|
|||||||
!!! LOOK into the pty crate to handle pseudoterminals such as in top or ssh
|
!!! LOOK into the pty crate to handle pseudoterminals such as in top or ssh
|
||||||
|
|
||||||
My starting point is [this article](https://www.joshmcguigan.com/blog/build-your-own-shell-rust/) which is excellent. I will start with the final form of a shell given in the article and try to reformat it:
|
My starting point is [this article](https://www.joshmcguigan.com/blog/build-your-own-shell-rust/) which is excellent. I will start with the final form of a shell given in the article and try to reformat it:
|
||||||
|
|
||||||
|
## To fix
|
||||||
|
* Autocomplete : when nothing found, return input
|
||||||
|
* Autocomplete : Weird permission issues sometimes (ignore unallowed files and folders)
|
||||||
|
10
src/lib.rs
10
src/lib.rs
@ -236,12 +236,6 @@ pub mod shell {
|
|||||||
let mut current_pos: usize = 0;
|
let mut current_pos: usize = 0;
|
||||||
let mut max_pos: usize = 0;
|
let mut max_pos: usize = 0;
|
||||||
|
|
||||||
//Used to keep the result of the last autocomplete
|
|
||||||
//Next time we press tab we get a different result so that we can
|
|
||||||
//rotate between files in the dir for example
|
|
||||||
//Resetted by pressing enter
|
|
||||||
let mut prev_autocomplete = String::new();
|
|
||||||
|
|
||||||
//Initialize
|
//Initialize
|
||||||
write!(stdout, "\r\n SquiShell (sqish)--- \r\n{}", prompt);
|
write!(stdout, "\r\n SquiShell (sqish)--- \r\n{}", prompt);
|
||||||
stdout.flush();
|
stdout.flush();
|
||||||
@ -255,8 +249,7 @@ pub mod shell {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Search
|
//Search
|
||||||
let (res, list) = autocomplete(&mycommand, &prev_autocomplete);
|
let (res, list) = autocomplete(&mycommand);
|
||||||
*&mut prev_autocomplete = String::from(res.as_str());
|
|
||||||
write!(stdout, "\r\n{}\r\n", list);
|
write!(stdout, "\r\n{}\r\n", list);
|
||||||
mycommand.clear();
|
mycommand.clear();
|
||||||
mycommand.push_str(&res);
|
mycommand.push_str(&res);
|
||||||
@ -267,7 +260,6 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Key::Char('\n') => {
|
Key::Char('\n') => {
|
||||||
*&mut prev_autocomplete = String::new();
|
|
||||||
current_number = get_curr_history_number();
|
current_number = get_curr_history_number();
|
||||||
prompt = build_prompt(¤t_number);
|
prompt = build_prompt(¤t_number);
|
||||||
current_pos = 0;
|
current_pos = 0;
|
||||||
|
@ -55,7 +55,7 @@ fn autocomplete_file(input: &String) -> std::io::Result<(String, String)> {
|
|||||||
if input_searchee.contains('/') {
|
if input_searchee.contains('/') {
|
||||||
//Correctly taking first and last part...
|
//Correctly taking first and last part...
|
||||||
let splitted_searchstring = &input_searchee.split('/');
|
let splitted_searchstring = &input_searchee.split('/');
|
||||||
let mut trimmed_searchee = &splitted_searchstring.clone().last().unwrap();
|
let trimmed_searchee = &splitted_searchstring.clone().last().unwrap();
|
||||||
let splitted_searchstring = &mut input_searchee.clone().split('/').collect::<Vec<&str>>();
|
let splitted_searchstring = &mut input_searchee.clone().split('/').collect::<Vec<&str>>();
|
||||||
splitted_searchstring.pop();
|
splitted_searchstring.pop();
|
||||||
let mut tosearch = splitted_searchstring.join("/");
|
let mut tosearch = splitted_searchstring.join("/");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user