Adapt cli code to changes
This commit is contained in:
parent
5e47dddd4c
commit
3f5e06b113
10 changed files with 101 additions and 90 deletions
|
|
@ -1,32 +1,18 @@
|
|||
use crate::eval::{Entry, EntryKind};
|
||||
use crate::files::Files;
|
||||
|
||||
use super::error::Result;
|
||||
use super::error::Error;
|
||||
use super::layout::line::LineLayout;
|
||||
|
||||
fn show_entry(files: &Files, entry: &Entry) {
|
||||
let command = files.command(entry.source);
|
||||
|
||||
match entry.kind {
|
||||
EntryKind::Task => println!("TASK {}", command.title()),
|
||||
EntryKind::TaskDone(when) => {
|
||||
println!("DONE {}", command.title());
|
||||
println!("DONE AT {}", when);
|
||||
}
|
||||
EntryKind::TaskCanceled(when) => {
|
||||
println!("CANCELED {}", command.title());
|
||||
println!("CANCELED AT {}", when);
|
||||
}
|
||||
EntryKind::Note => println!("NOTE {}", command.title()),
|
||||
EntryKind::Birthday(Some(age)) => {
|
||||
println!("BIRTHDAY {}", command.title());
|
||||
println!("AGE {}", age);
|
||||
}
|
||||
EntryKind::Birthday(None) => {
|
||||
println!("BIRTHDAY {}", command.title());
|
||||
println!("AGE UNKNOWN");
|
||||
}
|
||||
}
|
||||
let kind = match entry.kind {
|
||||
EntryKind::Task | EntryKind::TaskDone(_) | EntryKind::TaskCanceled(_) => "TASK",
|
||||
EntryKind::Note => "NOTE",
|
||||
EntryKind::Birthday(_) => "BIRTHDAY",
|
||||
};
|
||||
println!("{} {}", kind, entry.title);
|
||||
|
||||
if let Some(dates) = entry.dates {
|
||||
println!("DATE {}", dates.sorted());
|
||||
|
|
@ -34,17 +20,25 @@ fn show_entry(files: &Files, entry: &Entry) {
|
|||
println!("NO DATE");
|
||||
}
|
||||
|
||||
for line in command.desc() {
|
||||
println!("# {}", line);
|
||||
match entry.kind {
|
||||
EntryKind::TaskDone(when) => println!("DONE {}", when),
|
||||
EntryKind::TaskCanceled(when) => println!("CANCELED {}", when),
|
||||
EntryKind::Birthday(Some(age)) => println!("AGE {}", age),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
println!("FROM COMMAND");
|
||||
for line in format!("{}", command.command).lines() {
|
||||
println!("| {}", line);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show(
|
||||
pub fn show<S>(
|
||||
files: &Files,
|
||||
entries: &[Entry],
|
||||
layout: &LineLayout,
|
||||
numbers: &[usize],
|
||||
) -> Result<()> {
|
||||
) -> Result<(), Error<S>> {
|
||||
if numbers.is_empty() {
|
||||
// Nothing to do
|
||||
return Ok(());
|
||||
|
|
@ -53,7 +47,7 @@ pub fn show(
|
|||
let indices = numbers
|
||||
.iter()
|
||||
.map(|n| layout.look_up_number(*n))
|
||||
.collect::<Result<Vec<usize>>>()?;
|
||||
.collect::<Result<Vec<usize>, _>>()?;
|
||||
|
||||
show_entry(files, &entries[indices[0]]);
|
||||
for &index in indices.iter().skip(1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue