From 78136ac6220a2a4a82da68a9146c0135c6f9f893 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Sun, 17 Mar 2024 21:51:20 +0100 Subject: [PATCH] Make not enabling all optional features work --- src/main.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 394ab86..9f6ea47 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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") + } } }