sheet delegates to list when no argument is received
This commit is contained in:
parent
54bfa8ce8f
commit
1b57a0b297
|
@ -43,9 +43,9 @@ impl<'a> Command<'a> for ListCommand {
|
||||||
let now = Utc::now();
|
let now = Utc::now();
|
||||||
let today = Local::now().date().and_hms(0, 0, 0).with_timezone(&Utc);
|
let today = Local::now().date().and_hms(0, 0, 0).with_timezone(&Utc);
|
||||||
let mut sheets = if args.all {
|
let mut sheets = if args.all {
|
||||||
db.entries_all_visible(None, None)?
|
|
||||||
} else {
|
|
||||||
db.entries_full(None, None)?
|
db.entries_full(None, None)?
|
||||||
|
} else {
|
||||||
|
db.entries_all_visible(None, None)?
|
||||||
};
|
};
|
||||||
|
|
||||||
let current = db.current_sheet()?.unwrap_or("".into());
|
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.feed(vec!["".into(), "Timesheet".into(), "Running".into(), "Today".into(), "Total Time".into()]);
|
||||||
|
tabs.separator(' ');
|
||||||
|
|
||||||
for sheet in sheets {
|
for sheet in sheets {
|
||||||
tabs.feed(vec![sheet.0, sheet.1, sheet.2, sheet.3, sheet.4]);
|
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]
|
#[test]
|
||||||
fn list_sheets_shows_last() {
|
fn list_sheets_shows_last() {
|
||||||
assert!(false);
|
assert!(false);
|
||||||
|
|
|
@ -7,6 +7,7 @@ use crate::database::Database;
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::commands::Command;
|
use crate::commands::Command;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::commands::list::ListCommand;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
|
@ -28,7 +29,7 @@ pub struct SheetCommand {}
|
||||||
impl<'a> Command<'a> for SheetCommand {
|
impl<'a> Command<'a> for SheetCommand {
|
||||||
type Args = Args;
|
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
|
where
|
||||||
D: Database,
|
D: Database,
|
||||||
O: Write,
|
O: Write,
|
||||||
|
@ -39,7 +40,7 @@ impl<'a> Command<'a> for SheetCommand {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
} else {
|
} else {
|
||||||
// call list
|
// call list
|
||||||
Ok(())
|
ListCommand::handle(Default::default(), db, out, err, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,6 +247,7 @@ fn main() {
|
||||||
.visible_alias("l")
|
.visible_alias("l")
|
||||||
.about("List existing sheets")
|
.about("List existing sheets")
|
||||||
.arg(Arg::with_name("all")
|
.arg(Arg::with_name("all")
|
||||||
|
.short("a").long("all")
|
||||||
.help("List archive sheets also"))
|
.help("List archive sheets also"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue