This commit is contained in:
2024-12-01 21:00:29 +01:00
parent e8a52c1775
commit b41fbf8047
4 changed files with 69 additions and 51 deletions
+4 -11
View File
@@ -57,9 +57,8 @@ fn handle_push(args: &PushArgs, stack: &mut Stack) -> Result<()> {
Ok(())
}
fn handle_pop(_args: &PopArgs, stack: &mut Stack) -> Result<()> {
// TODO: handle arguments
let path = stack.pop_entry()?;
fn handle_pop(args: &PopArgs, stack: &mut Stack) -> Result<()> {
let path = stack.pop_entry(args.num_entries)?;
println!(
"cd -- {}",
match path.to_str() {
@@ -77,14 +76,8 @@ fn handle_stack(args: &StackArgs, stack: &mut Stack) -> Result<()> {
}
}
// retrieve stack
let output = stack.get_stack()?;
if output.is_empty() {
return Err(Error::other("-- the stack is empty"));
}
// print stack to standard output
for (n, item) in output.iter().rev().enumerate() {
println!("echo '{} - {}'", n, item.to_str().unwrap());
}
let output: String = stack.to_string(None)?;
print!("echo '{}'", output);
Ok(())
}