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::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 clap::Parser;
use editor::commands::fetch::fetch; use tracing::error;
use editor::commands::query::query;
use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::util::SubscriberInitExt;
mod args_parser; mod args_parser;
#[cfg(feature = "editor")] #[cfg(feature = "editor")]
mod 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; mod schema;
#[cfg(feature = "server")] #[cfg(feature = "server")]
mod server; mod server;
@ -30,6 +36,7 @@ fn main() {
.. ..
} = args; } = args;
match run_mode { match run_mode {
#[allow(unused_variables)] // For when the server feature is compiled out
Command::Serve(params) => { Command::Serve(params) => {
#[cfg(not(feature = "server"))] #[cfg(not(feature = "server"))]
{ {
@ -38,6 +45,7 @@ fn main() {
#[cfg(feature = "server")] #[cfg(feature = "server")]
server::init(data_paths, params); server::init(data_paths, params);
} }
#[cfg(feature = "editor")]
Command::Fetch { Command::Fetch {
save, save,
handles, handles,
@ -54,6 +62,7 @@ fn main() {
); );
reload(data_paths.pid_file_path, server_reload); reload(data_paths.pid_file_path, server_reload);
} }
#[cfg(feature = "editor")]
Command::Query { Command::Query {
save, save,
resource, resource,
@ -64,6 +73,7 @@ fn main() {
reload(data_paths.pid_file_path, server_reload); reload(data_paths.pid_file_path, server_reload);
} }
#[cfg(feature = "editor")]
Command::Editor { Command::Editor {
save, save,
resource, resource,
@ -74,11 +84,17 @@ fn main() {
reload(data_paths.pid_file_path, server_reload); reload(data_paths.pid_file_path, server_reload);
} }
#[cfg(feature = "editor")]
Command::Init { force } => { Command::Init { force } => {
init(data_paths.database_path, force); init(data_paths.database_path, force);
} }
#[cfg(feature = "editor")]
Command::List {} => { Command::List {} => {
list(data_paths.database_path); 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")
}
} }
} }