Skip to content

Commit 1843023

Browse files
committed
git
1 parent a251e3d commit 1843023

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ Cargo.lock
1111
**/*.rs.bk
1212

1313
# MSVC Windows builds of rustc generate these, which store debugging information
14-
*.pdb
15-
16-
hidden/
14+
*.pdb

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ regex = "0.1"
1212
reqwest = { version = "0.11.0", features = ["blocking"] }
1313
rodio = "0.17.3"
1414
sys-info = "0.7.0"
15-
clap = "3.0"
15+
clap = "3.0"
16+
clearscreen = "2.0.1"

src/main.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,11 +1378,45 @@ impl Executor {
13781378
})
13791379
}
13801380

1381+
<<<<<<< HEAD
1382+
=======
1383+
"index" => {
1384+
let findhint = self.pop_stack().get_string();
1385+
let findtarget = self.pop_stack().get_list();
1386+
1387+
for index in 0..(findtarget.len()) {
1388+
if findhint == findtarget[index].clone().get_string() {
1389+
self.stack.push(Type::Number(index as f64));
1390+
return;
1391+
}
1392+
}
1393+
self.log_print("Error! item not found in this list".to_owned() + "\n");
1394+
self.stack.push(Type::Error(String::from("item-not-found")));
1395+
}
1396+
1397+
"cls" => {
1398+
self.clearscreen();
1399+
}
1400+
1401+
"clear" => {
1402+
self.clearscreen();
1403+
}
1404+
1405+
>>>>>>> 887510b (git)
13811406
// If it is not recognized as a command, use it as a string.
13821407
_ => self.stack.push(Type::String(command)),
13831408
}
13841409
}
13851410

1411+
fn clearscreen(&mut self) {
1412+
let result = clearscreen::clear();
1413+
if result.is_err() {
1414+
println!("Error! Failed to clear screen");
1415+
self.stack
1416+
.push(Type::Error(String::from("failed-to-clear-screen")));
1417+
}
1418+
}
1419+
13861420
/// Pop stack's top value
13871421
fn pop_stack(&mut self) -> Type {
13881422
if let Some(value) = self.stack.pop() {

0 commit comments

Comments
 (0)