use clap::{Parser}; use tracing::info; use tracing_subscriber::util::SubscriberInitExt; use crate::args_parser::Command; use crate::editor::open_in_editor::open_resource_in_editor; use editor::commands::fetch::fetch; use editor::commands::query::query; use crate::editor::commands::editor::editor; use crate::editor::try_reload_server::reload; use crate::schema::lookup_handler::LookupHandler; mod schema; #[cfg(feature = "editor")] mod editor; #[cfg(feature = "server")] mod server; mod args_parser; #[cfg(all(not(feature = "editor"), not(feature = "server")))] compile_error!("Please enable either the \"editor\" or the \"server\" feature"); fn main() { let args = args_parser::MainCommand::parse(); tracing_subscriber::FmtSubscriber::builder() .with_max_level(args.log_level()) .finish().init(); let args_parser::MainCommand { data_paths, run_mode, .. } = args; match run_mode { Command::Serve(params) => { #[cfg(not(feature = "server"))] { panic!("Server mode has not been compiled into this executable. Please rebuild with the \"server\" feature enabled.") } #[cfg(feature = "server")] server::init(data_paths, params); } Command::Fetch { save, handles, handles_are_files, new_domain, server_reload } => { fetch(data_paths.database_path, save, handles.into_iter(), handles_are_files, new_domain); reload(data_paths.pid_file_path, server_reload); } Command::Query { resource } => { query(data_paths.database_path, resource) } Command::Editor { save, resource, server_reload } => { editor(data_paths.database_path, save, resource); reload(data_paths.pid_file_path, server_reload); } } }