mod cli;
mod config;
mod database;
mod graph;
mod io;
mod subcommands;
mod zettel;
use crate::config::*;
use crate::database::Database;
use crate::subcommands::*;
use crate::zettel::Zettel;
const SQL_ARRAY_SEPARATOR: &str = "::";
fn vec_to_str(vec: &[String]) -> String
{
format!("{}{}{}",
SQL_ARRAY_SEPARATOR,
vec.join(SQL_ARRAY_SEPARATOR),
SQL_ARRAY_SEPARATOR,)
}
fn str_to_vec(str: &str) -> Vec<String>
{
str.split(SQL_ARRAY_SEPARATOR)
.filter(|s| s != &"")
.map(|s| s.to_string())
.collect()
}
fn main() -> Result<(), rusqlite::Error>
{
let matches = cli::build().get_matches();
let cfg = ConfigOptions::load();
io::mkdir(&cfg.zettelkasten);
io::mkdir(&format!("{}/inbox", &cfg.zettelkasten));
let cmd = matches.subcommand_name().unwrap_or_default();
let cmd_matches = matches.subcommand_matches(cmd).unwrap();
match cmd {
"sync" => sync(cmd_matches, &cfg)?,
"query" => query(cmd_matches, &cfg)?,
"ls" => ls(cmd_matches, &cfg)?,
"compl" => compl(cmd_matches)?,
_ => (),
};
Ok(())
}