70 lines
2 KiB
Rust
70 lines
2 KiB
Rust
use crate::args_parser::Command;
|
|
use crate::editor::commands::editor::editor;
|
|
use crate::editor::commands::init::init;
|
|
use crate::editor::try_reload_server::reload;
|
|
use clap::Parser;
|
|
use editor::commands::fetch::fetch;
|
|
use editor::commands::query::query;
|
|
use tracing_subscriber::util::SubscriberInitExt;
|
|
|
|
mod args_parser;
|
|
#[cfg(feature = "editor")]
|
|
mod editor;
|
|
mod schema;
|
|
#[cfg(feature = "server")]
|
|
mod server;
|
|
|
|
#[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);
|
|
}
|
|
Command::Init { force } => {
|
|
init(data_paths.database_path, force);
|
|
}
|
|
}
|
|
}
|