aboutsummaryrefslogtreecommitdiff
path: root/apps/cassiopeia/src/format
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-11 18:35:07 +0000
committerMx Kookie <kookie@spacekookie.de>2020-12-21 05:19:49 +0100
commitfc7b4109c75299a2ee8debaccc73721338946cfa (patch)
treef9553d6b42f02629e7289d63b28a68aa68fa3ad4 /apps/cassiopeia/src/format
parentd40e014aebc778939ae8d9afae225b7d4f6cc949 (diff)
cassiopeia: changing project structure and adding CLI parsing
Diffstat (limited to 'apps/cassiopeia/src/format')
-rw-r--r--apps/cassiopeia/src/format/mod.rs5
-rw-r--r--apps/cassiopeia/src/format/parser.rs9
2 files changed, 7 insertions, 7 deletions
diff --git a/apps/cassiopeia/src/format/mod.rs b/apps/cassiopeia/src/format/mod.rs
index bac0445d8387..b5342d62da13 100644
--- a/apps/cassiopeia/src/format/mod.rs
+++ b/apps/cassiopeia/src/format/mod.rs
@@ -9,10 +9,7 @@ pub(crate) use parser::LineCfg;
use crate::TimeFile;
use std::{fs::File, io::Read};
-/// The cassiopeia parser/generator version to be written back into the file
-pub const CASS_VERSION: &str = env!("CARGO_PKG_VERSION");
-
-pub(crate) fn load_file(path: &str) -> TimeFile {
+pub fn load_file(path: &str) -> TimeFile {
let mut f = File::open(path).unwrap();
let mut content = String::new();
f.read_to_string(&mut content).unwrap();
diff --git a/apps/cassiopeia/src/format/parser.rs b/apps/cassiopeia/src/format/parser.rs
index bb2c56be0f33..430fee6332a7 100644
--- a/apps/cassiopeia/src/format/parser.rs
+++ b/apps/cassiopeia/src/format/parser.rs
@@ -4,7 +4,7 @@
//! parsed time file.
use crate::format::{LineLexer, LineToken, Token};
-use chrono::{NaiveDate, DateTime, FixedOffset as Offset};
+use chrono::{DateTime, FixedOffset as Offset, NaiveDate};
use std::collections::BTreeMap;
use std::iter::Iterator;
@@ -36,7 +36,7 @@ impl LineCfg {
pub(crate) fn parse<'l>(lex: LineLexer<'l>) -> LineCfg {
use LineCfg::*;
use Token as T;
-
+
#[cfg_attr(rustfmt, rustfmt_skip)]
lex.get_all().into_iter().fold(Ignore, |cfg, tok| match (cfg, tok) {
// If the first token is a comment, we ignore it
@@ -72,5 +72,8 @@ fn parse_datetime(slice: &str) -> Option<DateTime<Offset>> {
}
fn parse_date(slice: &str) -> Option<NaiveDate> {
- Some(NaiveDate::parse_from_str(slice, "%Y-%m-%d").expect("Failed to parse date; invalid format!"))
+ Some(
+ NaiveDate::parse_from_str(slice, "%Y-%m-%d")
+ .expect("Failed to parse date; invalid format!"),
+ )
}