Make not enabling all optional features work

This commit is contained in:
Karcsesz 2024-03-17 21:51:20 +01:00
parent 1e8b7a1105
commit 78136ac622

View file

@ -1,16 +1,22 @@
use crate::args_parser::Command;
use crate::editor::commands::editor::editor;
use crate::editor::commands::init::init;
use crate::editor::commands::list::list;
use crate::editor::try_reload_server::reload;
use clap::Parser;
use editor::commands::fetch::fetch;
use editor::commands::query::query;
use tracing::error;
use tracing_subscriber::util::SubscriberInitExt;
mod args_parser;
#[cfg(feature = "editor")]
mod editor;
#[cfg(feature = "editor")]
use editor::{
try_reload_server::reload,
commands::{
editor::editor,
init::init,
list::list,
fetch::fetch,
query::query
}
};
mod schema;
#[cfg(feature = "server")]
mod server;
@ -30,6 +36,7 @@ fn main() {
..
} = args;
match run_mode {
#[allow(unused_variables)] // For when the server feature is compiled out
Command::Serve(params) => {
#[cfg(not(feature = "server"))]
{
@ -38,6 +45,7 @@ fn main() {
#[cfg(feature = "server")]
server::init(data_paths, params);
}
#[cfg(feature = "editor")]
Command::Fetch {
save,
handles,
@ -54,6 +62,7 @@ fn main() {
);
reload(data_paths.pid_file_path, server_reload);
}
#[cfg(feature = "editor")]
Command::Query {
save,
resource,
@ -64,6 +73,7 @@ fn main() {
reload(data_paths.pid_file_path, server_reload);
}
#[cfg(feature = "editor")]
Command::Editor {
save,
resource,
@ -74,11 +84,17 @@ fn main() {
reload(data_paths.pid_file_path, server_reload);
}
#[cfg(feature = "editor")]
Command::Init { force } => {
init(data_paths.database_path, force);
}
#[cfg(feature = "editor")]
Command::List {} => {
list(data_paths.database_path);
}
#[allow(unreachable_patterns)] // This is a catch-all if the editor feature is disabled
_ => {
error!("The requested command is not supported by this build. Please rebuild with the \"editor\" feature enabled")
}
}
}