Skip to content
Snippets Groups Projects
Commit 4de69b54 authored by Éloïs's avatar Éloïs
Browse files

[fix] durs+core: cargo env vars must be call in binary crate

parent 787825ff
No related branches found
No related tags found
1 merge request!144Elois/fix gt sync
...@@ -42,42 +42,36 @@ pub use durs_tui::TuiModule; ...@@ -42,42 +42,36 @@ pub use durs_tui::TuiModule;
pub use durs_ws2p_v1_legacy::{WS2PModule, WS2POpt}; pub use durs_ws2p_v1_legacy::{WS2PModule, WS2POpt};
//pub use durs_ws2p::WS2Pv2Module; //pub use durs_ws2p::WS2Pv2Module;
/// Durs cli main macro
macro_rules! durs_cli_main {
( $closure_plug:expr ) => {{
init();
if let Err(err) = DursCliOpt::from_args().into_durs_command().execute(
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
$closure_plug,
) {
println!("{}", err);
error!("{}", err);
}
}};
}
/// Durs command line edition, main function /// Durs command line edition, main function
#[cfg(unix)] #[cfg(unix)]
#[cfg(not(target_arch = "arm"))] #[cfg(not(target_arch = "arm"))]
fn main() { fn main() {
init(); durs_cli_main!(durs_plug!(
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!(
[WS2PModule], [WS2PModule],
[TuiModule /*, SkeletonModule ,DasaModule*/] [TuiModule /*, SkeletonModule ,DasaModule*/]
)) ))
{
println!("{}", err);
error!("{}", err);
}
} }
#[cfg(unix)] #[cfg(unix)]
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
fn main() { fn main() {
init(); durs_cli_main!(durs_plug!([WS2PModule], [TuiModule /*, SkeletonModule*/]))
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!([WS2PModule], [TuiModule /*, SkeletonModule*/]))
{
println!("{}", err);
error!("{}", err);
}
} }
#[cfg(windows)] #[cfg(windows)]
fn main() { fn main() {
init(); durs_cli_main!(durs_plug!([WS2PModule], []))
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!([WS2PModule], []))
{
println!("{}", err);
error!("{}", err);
}
} }
...@@ -22,7 +22,7 @@ pub mod reset; ...@@ -22,7 +22,7 @@ pub mod reset;
pub mod start; pub mod start;
use crate::errors::DursCoreError; use crate::errors::DursCoreError;
use crate::{durs_exec_core_cmd, DursCore}; use crate::DursCore;
pub use dbex::*; pub use dbex::*;
pub use duniter_network::cli::sync::SyncOpt; pub use duniter_network::cli::sync::SyncOpt;
use durs_conf::DuRsConf; use durs_conf::DuRsConf;
...@@ -77,14 +77,24 @@ pub enum DursCommandEnum<T: ExecutableModuleCommand> { ...@@ -77,14 +77,24 @@ pub enum DursCommandEnum<T: ExecutableModuleCommand> {
impl<T: ExecutableModuleCommand> DursCommand<T> { impl<T: ExecutableModuleCommand> DursCommand<T> {
/// Execute Durs command /// Execute Durs command
pub fn execute<PlugFunc>(self, plug_modules: PlugFunc) -> Result<(), DursCoreError> pub fn execute<PlugFunc>(
self,
soft_name: &'static str,
soft_version: &'static str,
plug_modules: PlugFunc,
) -> Result<(), DursCoreError>
where where
PlugFunc: FnMut(&mut DursCore<DuRsConf>) -> Result<(), DursCoreError>, PlugFunc: FnMut(&mut DursCore<DuRsConf>) -> Result<(), DursCoreError>,
{ {
match self.command { match self.command {
DursCommandEnum::Core(core_cmd) => { DursCommandEnum::Core(core_cmd) => DursCore::execute_core_command(
durs_exec_core_cmd!(core_cmd, self.options, plug_modules,) core_cmd,
} self.options,
vec![],
plug_modules,
soft_name,
soft_version,
),
DursCommandEnum::Other(cmd) => cmd.execute_module_command(self.options), DursCommandEnum::Other(cmd) => cmd.execute_module_command(self.options),
} }
} }
......
...@@ -56,21 +56,6 @@ use std::path::PathBuf; ...@@ -56,21 +56,6 @@ use std::path::PathBuf;
use std::sync::mpsc; use std::sync::mpsc;
use std::thread; use std::thread;
#[macro_export]
/// Durs execute core command
macro_rules! durs_exec_core_cmd {
( $core_command:expr, $options:expr, $closure_plug:expr, ) => {{
DursCore::execute_core_command(
$core_command,
$options,
vec![],
$closure_plug,
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
)
}};
}
#[macro_export] #[macro_export]
/// Plug modules in durs core /// Plug modules in durs core
macro_rules! durs_plug { macro_rules! durs_plug {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment