Skip to content

Commit

Permalink
Fix the other commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdy committed May 31, 2022
1 parent 9bd5e0f commit 41b14fa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
37 changes: 20 additions & 17 deletions zerostash/src/commands/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@ pub struct Log {
impl Runnable for Log {
/// Start the application.
fn run(&self) {
let mut stash = APP.open_stash(&self.stash);
stash.load_all().unwrap();
abscissa_tokio::run(&APP, async {
let mut stash = APP.open_stash(&self.stash);
stash.load_all().unwrap();

for commit in stash.commit_list().iter() {
let time: DateTime<Utc> = commit.metadata.time.into();
let local_time = time.with_timezone(&chrono::Local);
let formatted_time = local_time.format("%Y %b %e %H:%M:%S").to_string();
for commit in stash.commit_list().iter() {
let time: DateTime<Utc> = commit.metadata.time.into();
let local_time = time.with_timezone(&chrono::Local);
let formatted_time = local_time.format("%Y %b %e %H:%M:%S").to_string();

println!(
"{:?}\t{}\t{}",
commit.id,
formatted_time,
commit
.metadata
.message
.as_ref()
.unwrap_or(&"No commit message".to_string())
);
}
println!(
"{:?}\t{}\t{}",
commit.id,
formatted_time,
commit
.metadata
.message
.as_ref()
.unwrap_or(&"No commit message".to_string())
);
}
})
.unwrap();
}
}
29 changes: 16 additions & 13 deletions zerostash/src/commands/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ pub struct Ls {
impl Runnable for Ls {
/// Start the application.
fn run(&self) {
let mut stash = APP.open_stash(&self.stash);

stash.load_all().unwrap();
let count = self
.options
.list(&stash)
.map(match self.list {
false => self.print_simple(),
true => self.print_list(),
})
.count();

writeln!(stderr().lock(), "Total entries: {}", count).unwrap();
abscissa_tokio::run(&APP, async {
let mut stash = APP.open_stash(&self.stash);

stash.load_all().unwrap();
let count = self
.options
.list(&stash)
.map(match self.list {
false => self.print_simple(),
true => self.print_list(),
})
.count();

writeln!(stderr().lock(), "Total entries: {}", count).unwrap();
})
.unwrap();
}
}

Expand Down

0 comments on commit 41b14fa

Please sign in to comment.