sheet delegates to list when no argument is received

This commit is contained in:
Abraham Toriz 2021-07-15 16:36:24 -05:00
parent 54bfa8ce8f
commit 1b57a0b297
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
3 changed files with 17 additions and 4 deletions

View File

@ -43,9 +43,9 @@ impl<'a> Command<'a> for ListCommand {
let now = Utc::now();
let today = Local::now().date().and_hms(0, 0, 0).with_timezone(&Utc);
let mut sheets = if args.all {
db.entries_all_visible(None, None)?
} else {
db.entries_full(None, None)?
} else {
db.entries_all_visible(None, None)?
};
let current = db.current_sheet()?.unwrap_or("".into());
@ -104,6 +104,7 @@ impl<'a> Command<'a> for ListCommand {
]);
tabs.feed(vec!["".into(), "Timesheet".into(), "Running".into(), "Today".into(), "Total Time".into()]);
tabs.separator(' ');
for sheet in sheets {
tabs.feed(vec![sheet.0, sheet.1, sheet.2, sheet.3, sheet.4]);
@ -149,6 +150,16 @@ mod tests {
"));
}
#[test]
fn show_all_sheets() {
assert!(false);
}
#[test]
fn show_warning_if_old_database() {
assert!(false);
}
#[test]
fn list_sheets_shows_last() {
assert!(false);

View File

@ -7,6 +7,7 @@ use crate::database::Database;
use crate::error::{Error, Result};
use crate::commands::Command;
use crate::config::Config;
use crate::commands::list::ListCommand;
#[derive(Default)]
pub struct Args {
@ -28,7 +29,7 @@ pub struct SheetCommand {}
impl<'a> Command<'a> for SheetCommand {
type Args = Args;
fn handle<D, O, E>(args: Args, _db: &mut D, _out: &mut O, _err: &mut E, _config: &Config) -> Result<()>
fn handle<D, O, E>(args: Args, db: &mut D, out: &mut O, err: &mut E, config: &Config) -> Result<()>
where
D: Database,
O: Write,
@ -39,7 +40,7 @@ impl<'a> Command<'a> for SheetCommand {
unimplemented!()
} else {
// call list
Ok(())
ListCommand::handle(Default::default(), db, out, err, config)
}
}
}

View File

@ -247,6 +247,7 @@ fn main() {
.visible_alias("l")
.about("List existing sheets")
.arg(Arg::with_name("all")
.short("a").long("all")
.help("List archive sheets also"))
)