Cleanup ingestions

This commit is contained in:
xqtc 2024-10-11 20:44:11 +02:00
parent 28ba4e988f
commit 51ad2bf67e
5 changed files with 129 additions and 278 deletions

185
Cargo.lock generated
View file

@ -102,12 +102,6 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
] ]
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]] [[package]]
name = "bincode" name = "bincode"
version = "1.3.3" version = "1.3.3"
@ -128,9 +122,6 @@ name = "bitflags"
version = "2.6.0" version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
@ -150,8 +141,6 @@ version = "1.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1"
dependencies = [ dependencies = [
"jobserver",
"libc",
"shlex", "shlex",
] ]
@ -302,15 +291,6 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "form_urlencoded"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
dependencies = [
"percent-encoding",
]
[[package]] [[package]]
name = "fuzzy-matcher" name = "fuzzy-matcher"
version = "0.3.7" version = "0.3.7"
@ -346,21 +326,6 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "git2"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724"
dependencies = [
"bitflags 2.6.0",
"libc",
"libgit2-sys",
"log",
"openssl-probe",
"openssl-sys",
"url",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.0" version = "0.15.0"
@ -396,16 +361,6 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "idna"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
dependencies = [
"unicode-bidi",
"unicode-normalization",
]
[[package]] [[package]]
name = "indenter" name = "indenter"
version = "0.3.3" version = "0.3.3"
@ -445,15 +400,6 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "jobserver"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.70" version = "0.3.70"
@ -475,46 +421,6 @@ version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]]
name = "libgit2-sys"
version = "0.17.0+1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224"
dependencies = [
"cc",
"libc",
"libssh2-sys",
"libz-sys",
"openssl-sys",
"pkg-config",
]
[[package]]
name = "libssh2-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
]
[[package]]
name = "libz-sys"
version = "1.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.12"
@ -545,10 +451,8 @@ dependencies = [
"chrono", "chrono",
"clap", "clap",
"color-eyre", "color-eyre",
"git2",
"inquire", "inquire",
"lazy_static", "lazy_static",
"ron",
"serde", "serde",
"strum", "strum",
"strum_macros", "strum_macros",
@ -610,24 +514,6 @@ version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "owo-colors" name = "owo-colors"
version = "3.5.0" version = "3.5.0"
@ -657,24 +543,12 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "percent-encoding"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.14" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
[[package]]
name = "pkg-config"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.87" version = "1.0.87"
@ -702,18 +576,6 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
] ]
[[package]]
name = "ron"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [
"base64",
"bitflags 2.6.0",
"serde",
"serde_derive",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.24" version = "0.1.24"
@ -861,21 +723,6 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "tinyvec"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.19" version = "0.8.19"
@ -951,27 +798,12 @@ dependencies = [
"tracing-core", "tracing-core",
] ]
[[package]]
name = "unicode-bidi"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.13" version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "unicode-normalization"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
dependencies = [
"tinyvec",
]
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.12.0" version = "1.12.0"
@ -984,17 +816,6 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
[[package]]
name = "url"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
]
[[package]] [[package]]
name = "utf8parse" name = "utf8parse"
version = "0.2.2" version = "0.2.2"
@ -1017,12 +838,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"

View file

@ -8,10 +8,8 @@ bincode = "1.3.3"
chrono = { version = "0.4.38", features = ["serde"] } chrono = { version = "0.4.38", features = ["serde"] }
clap = { version = "4.5.20", features = ["derive"] } clap = { version = "4.5.20", features = ["derive"] }
color-eyre = "0.6.3" color-eyre = "0.6.3"
git2 = "0.19.0"
inquire = "0.7.5" inquire = "0.7.5"
lazy_static = "1.5.0" lazy_static = "1.5.0"
ron = "0.8.1"
serde = { version = "1.0.210", features = ["derive"] } serde = { version = "1.0.210", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] } strum = { version = "0.26.3", features = ["derive"] }
strum_macros = "0.26.4" strum_macros = "0.26.4"

View file

@ -1,3 +1,7 @@
use crate::ingestions_util::{
self, ensure_ingestion_files, get_dose_unit, get_ingestion_confirmation, get_ingestion_method,
get_substance, get_user_datetime,
};
use chrono::{NaiveDateTime, Utc}; use chrono::{NaiveDateTime, Utc};
use color_eyre::Section; use color_eyre::Section;
use inquire; use inquire;
@ -9,17 +13,17 @@ use uuid::Uuid;
use crate::{config::INGESTIONS_FILE, substances::Substance}; use crate::{config::INGESTIONS_FILE, substances::Substance};
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
struct Ingestion { pub struct Ingestion {
substance: String, pub substance: String,
dose: Dose, pub dose: Dose,
ingest_method: IngestionMethod, pub ingestion_method: IngestionMethod,
time: NaiveDateTime, pub time: NaiveDateTime,
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
struct Dose { pub struct Dose {
unit: String, pub unit: String,
value: f64, pub value: f64,
} }
#[derive(Serialize, Deserialize, Debug, strum::Display, strum::EnumIter)] #[derive(Serialize, Deserialize, Debug, strum::Display, strum::EnumIter)]
@ -47,77 +51,29 @@ pub enum IngestionMethod {
} }
pub fn add_ingestion() { pub fn add_ingestion() {
let mut ingesstions_bytes_loaded_des: HashMap<Uuid, Ingestion>; let mut ingesstions_bytes_loaded_des: HashMap<Uuid, Ingestion> = ensure_ingestion_files();
if crate::substances::path_exists(INGESTIONS_FILE.to_string()) {
let substances_bytes_loaded = std::fs::read(INGESTIONS_FILE.to_string()).unwrap();
ingesstions_bytes_loaded_des = bincode::deserialize(&substances_bytes_loaded).unwrap();
} else {
std::fs::File::create(INGESTIONS_FILE.to_string()).unwrap();
ingesstions_bytes_loaded_des = HashMap::new();
let ingesstions_bytes_loaded_ser =
bincode::serialize(&ingesstions_bytes_loaded_des).unwrap();
std::fs::write(INGESTIONS_FILE.to_string(), ingesstions_bytes_loaded_ser).unwrap();
}
let substances = crate::substances::substances_to_vec();
if substances.is_empty() {
eprintln!("Add a substance before you log an ingestions");
exit(1)
}
let substance = inquire::Select::new("What did yout ingest?", substances)
.prompt()
.unwrap();
let ingestion_method_select = inquire::Select::new(
"How did you ingest?",
IngestionMethod::iter().collect::<Vec<_>>(),
)
.prompt()
.unwrap();
dbg!(&substance); let substance = get_substance();
dbg!(&ingestion_method_select);
let current_time = Utc::now().naive_utc();
let date_time: chrono::NaiveDateTime = inquire::CustomType::<chrono::NaiveDateTime>::new( let ingestion_method = get_ingestion_method();
"Enter the date and time (YYYY-MM-DD HH:MM):",
) let time: NaiveDateTime = get_user_datetime();
.with_placeholder("YYYY-MM-DD HH:MM")
.with_default(current_time)
.with_parser(&|input| {
chrono::NaiveDateTime::parse_from_str(input, "%Y-%m-%d %H:%M").map_err(|_| ())
})
.with_error_message("Please enter a valid date and time in the format YYYY-MM-DD HH:MM.")
.with_help_message("Use the format YYYY-MM-DD HH:MM")
.prompt()
.unwrap();
let dose_num: f64 = inquire::prompt_f64("Enter the amount consumed:").unwrap(); let dose_num: f64 = inquire::prompt_f64("Enter the amount consumed:").unwrap();
let dose_unit = inquire::Select::new( let dose_unit: DoseUnit = get_dose_unit();
"What unit should be used?",
DoseUnit::iter().collect::<Vec<_>>(),
)
.prompt()
.unwrap();
let dose = Dose { let dose = Dose {
unit: dose_unit.to_string(), unit: dose_unit.to_string(),
value: dose_num, value: dose_num,
}; };
let ingestion = Ingestion { let ingestion = Ingestion {
substance, substance,
dose, dose,
ingest_method: ingestion_method_select, ingestion_method,
time: date_time, time,
}; };
println!(
"Substance: {} ({})\nDose: {}{}\nTime: {}\n", let confirm = get_ingestion_confirmation(ingestion.clone());
ingestion.substance,
ingestion.ingest_method,
ingestion.dose.value,
ingestion.dose.unit,
ingestion.time,
);
let confirm =
inquire::prompt_confirmation("Does the ingestion above look alright? [y/N]").unwrap();
dbg!(&confirm);
if confirm { if confirm {
ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone()); ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone());
let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap(); let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap();
@ -134,7 +90,7 @@ pub fn list_ingestions() -> Result<(), std::io::Error> {
println!( println!(
"Substance: {} ({})\nDose: {}{}\nTime: {}\nUUID: {:?}\n", "Substance: {} ({})\nDose: {}{}\nTime: {}\nUUID: {:?}\n",
ingestion.substance, ingestion.substance,
ingestion.ingest_method, ingestion.ingestion_method,
ingestion.dose.value, ingestion.dose.value,
ingestion.dose.unit, ingestion.dose.unit,
ingestion.time, ingestion.time,

87
src/ingestions_util.rs Normal file
View file

@ -0,0 +1,87 @@
use crate::ingestions::{DoseUnit, Ingestion, IngestionMethod};
use crate::{config::INGESTIONS_FILE, substances::Substance};
use chrono::{NaiveDateTime, Utc};
use color_eyre::Section;
use inquire;
use serde::{self, Deserialize, Serialize};
use std::{collections::HashMap, process::exit};
use strum::{EnumIter, IntoEnumIterator};
use uuid::Uuid;
pub fn ensure_ingestion_files() -> HashMap<Uuid, Ingestion> {
let mut ingesstions_bytes_loaded_des: HashMap<Uuid, Ingestion>;
if crate::substances::path_exists(INGESTIONS_FILE.to_string()) {
let substances_bytes_loaded = std::fs::read(INGESTIONS_FILE.to_string()).unwrap();
ingesstions_bytes_loaded_des = bincode::deserialize(&substances_bytes_loaded).unwrap();
} else {
std::fs::File::create(INGESTIONS_FILE.to_string()).unwrap();
ingesstions_bytes_loaded_des = HashMap::new();
let ingesstions_bytes_loaded_ser =
bincode::serialize(&ingesstions_bytes_loaded_des).unwrap();
std::fs::write(INGESTIONS_FILE.to_string(), ingesstions_bytes_loaded_ser).unwrap();
}
ingesstions_bytes_loaded_des
}
pub fn get_user_datetime() -> chrono::NaiveDateTime {
let current_time = Utc::now().naive_utc();
let date_time: chrono::NaiveDateTime = inquire::CustomType::<chrono::NaiveDateTime>::new(
"Enter the date and time (YYYY-MM-DD HH:MM):",
)
.with_placeholder("YYYY-MM-DD HH:MM")
.with_default(current_time)
.with_parser(&|input| {
chrono::NaiveDateTime::parse_from_str(input, "%Y-%m-%d %H:%M").map_err(|_| ())
})
.with_error_message("Please enter a valid date and time in the format YYYY-MM-DD HH:MM.")
.with_help_message("Use the format YYYY-MM-DD HH:MM")
.prompt()
.unwrap();
date_time
}
pub fn get_dose_unit() -> DoseUnit {
let dose_unit = inquire::Select::new(
"What unit should be used?",
DoseUnit::iter().collect::<Vec<_>>(),
)
.prompt()
.unwrap();
dose_unit
}
pub fn get_substance() -> String {
let substances = crate::substances::substances_to_vec();
if substances.is_empty() {
eprintln!("Add a substance before you log an ingestions");
exit(1)
}
let substance = inquire::Select::new("What did yout ingest?", substances)
.prompt()
.unwrap();
substance
}
pub fn get_ingestion_method() -> IngestionMethod {
let ingestion_method = inquire::Select::new(
"How did you ingest?",
IngestionMethod::iter().collect::<Vec<_>>(),
)
.prompt()
.unwrap();
ingestion_method
}
pub fn get_ingestion_confirmation(ingestion: Ingestion) -> bool {
println!(
"Substance: {} ({})\nDose: {}{}\nTime: {}\n",
ingestion.substance,
ingestion.ingestion_method,
ingestion.dose.value,
ingestion.dose.unit,
ingestion.time,
);
let confirm =
inquire::prompt_confirmation("Does the ingestion above look alright? [y/N]").unwrap();
confirm
}

View file

@ -1,19 +1,12 @@
use core::panic; use core::panic;
use std::{collections::HashMap, path::Path};
use bincode::serialize;
use chrono::Utc;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use config::{INGESTIONS_FILE, LOCAL_PATH, SUBSTANCES_FILE}; use config::{INGESTIONS_FILE, LOCAL_PATH, SUBSTANCES_FILE};
use git2;
use inquire;
use serde::{self, Deserialize, Serialize};
use strum::{EnumIter, IntoEnumIterator};
use uuid::Uuid;
mod config; mod config;
mod ingestions; mod ingestions;
mod ingestions_util;
mod substances; mod substances;
#[derive(Parser)] #[derive(Parser)]
@ -53,8 +46,23 @@ enum Commands {
} }
fn main() { fn main() {
// let home = std::env::var("HOME").unwrap(); ensure_files();
// let local_path = format!("{}/.local/share/meowlog", &home); let cli = Cli::parse();
match &cli.command {
Some(Commands::AddIngestion) => ingestions::add_ingestion(),
Some(Commands::EditIngestion) => {}
Some(Commands::ListIngestions) => ingestions::list_ingestions().unwrap(),
Some(Commands::RemoveIngestion) => {}
Some(Commands::AddSubstance) => substances::add_substance().unwrap(),
Some(Commands::EditSubstance) => {}
Some(Commands::ListSubstances) => substances::list_substances().unwrap(),
Some(Commands::RemoveSubstance) => {}
None => {}
}
}
fn ensure_files() {
if !substances::path_exists(LOCAL_PATH.to_string()) { if !substances::path_exists(LOCAL_PATH.to_string()) {
match std::fs::create_dir(LOCAL_PATH.to_string()) { match std::fs::create_dir(LOCAL_PATH.to_string()) {
Ok(_) => {} Ok(_) => {}
@ -92,17 +100,4 @@ fn main() {
} }
}; };
} }
let cli = Cli::parse();
match &cli.command {
Some(Commands::AddIngestion) => ingestions::add_ingestion(),
Some(Commands::EditIngestion) => {}
Some(Commands::ListIngestions) => ingestions::list_ingestions().unwrap(),
Some(Commands::RemoveIngestion) => {}
Some(Commands::AddSubstance) => substances::add_substance().unwrap(),
Some(Commands::EditSubstance) => {}
Some(Commands::ListSubstances) => substances::list_substances().unwrap(),
Some(Commands::RemoveSubstance) => {}
None => {}
}
} }