aboutsummaryrefslogtreecommitdiff
path: root/apps/cassiopeia/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/cassiopeia/src/lib.rs')
-rw-r--r--apps/cassiopeia/src/lib.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/apps/cassiopeia/src/lib.rs b/apps/cassiopeia/src/lib.rs
index 1ea50fb8bc17..d4ebf5355bb9 100644
--- a/apps/cassiopeia/src/lib.rs
+++ b/apps/cassiopeia/src/lib.rs
@@ -9,28 +9,32 @@
//! https://git.spacekookie.de/kookienomicon/tree/apps/cassiopeia
mod data;
+mod date;
mod format;
pub mod meta;
mod time;
-pub use data::{Session, TimeFile};
+pub use date::Date;
pub use format::load_file;
+pub use time::Time;
-/// A state handler for all cass interactions
+use data::{Invoice, Session, TimeFile};
+use format::{ir, IrStream, ParseOutput};
+
+/// A state handler and primary API for all cass interactions
+///
///
-/// This could be a stateless API, but I like being able to refer to
-/// fields that need to be saved for later here. This API wraps
-/// around [`TimeFile`](crate::TimeFile), so that you don't have to! ✨
pub struct Cassiopeia {
path: String,
tf: TimeFile,
+ ir: IrStream,
}
impl Cassiopeia {
/// Load a cass file from disk, parsing it into a [`TimeFile`](crate::TimeFile)
pub fn load(path: &str) -> Option<Self> {
let path = path.to_owned();
- load_file(path.as_str()).map(|tf| Self { path, tf })
+ load_file(path.as_str()).map(|ParseOutput { tf, ir }| Self { path, tf, ir })
}
/// Store the modified time file back to disk
@@ -40,11 +44,15 @@ impl Cassiopeia {
/// Start a new work session (with optional 15 minute rounding)
pub fn start(&mut self, round: bool) -> Option<()> {
- self.tf.start(round)
+ self.tf.start(round)?;
+
+ Some(())
}
/// Stop the existing work session (with optional 15 minute rounding)
pub fn stop(&mut self, round: bool) -> Option<()> {
+ self.tf.stop(round)?;
+
Some(())
}
@@ -96,7 +104,7 @@ impl<'cass> Invoicer<'cass> {
}
}
- /// S
+ /// Enable the invoice generation feature
pub fn generate(self) -> Self {
Self {
generate: true,
@@ -120,10 +128,12 @@ impl<'cass> Invoicer<'cass> {
pub fn run(self) -> Option<()> {
if self.generate {
- eprintln!("Integration with invoice(1) is currently not implemented. Sorry :()");
+ eprintln!("Integration with invoice(1) is currently not implemented. Sorry :(");
return None;
}
- None
+ self.tf.tf.invoice()?;
+
+ Some(())
}
}