Commit 4de69b54 authored by Éloïs's avatar Éloïs

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

parent 787825ff
......@@ -42,42 +42,36 @@ pub use durs_tui::TuiModule;
pub use durs_ws2p_v1_legacy::{WS2PModule, WS2POpt};
//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
#[cfg(unix)]
#[cfg(not(target_arch = "arm"))]
fn main() {
init();
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!(
[WS2PModule],
[TuiModule /*, SkeletonModule ,DasaModule*/]
))
{
println!("{}", err);
error!("{}", err);
}
durs_cli_main!(durs_plug!(
[WS2PModule],
[TuiModule /*, SkeletonModule ,DasaModule*/]
))
}
#[cfg(unix)]
#[cfg(target_arch = "arm")]
fn main() {
init();
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!([WS2PModule], [TuiModule /*, SkeletonModule*/]))
{
println!("{}", err);
error!("{}", err);
}
durs_cli_main!(durs_plug!([WS2PModule], [TuiModule /*, SkeletonModule*/]))
}
#[cfg(windows)]
fn main() {
init();
if let Err(err) = DursCliOpt::from_args()
.into_durs_command()
.execute(durs_plug!([WS2PModule], []))
{
println!("{}", err);
error!("{}", err);
}
durs_cli_main!(durs_plug!([WS2PModule], []))
}
......@@ -22,7 +22,7 @@ pub mod reset;
pub mod start;
use crate::errors::DursCoreError;
use crate::{durs_exec_core_cmd, DursCore};
use crate::DursCore;
pub use dbex::*;
pub use duniter_network::cli::sync::SyncOpt;
use durs_conf::DuRsConf;
......@@ -77,14 +77,24 @@ pub enum DursCommandEnum<T: ExecutableModuleCommand> {
impl<T: ExecutableModuleCommand> DursCommand<T> {
/// 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
PlugFunc: FnMut(&mut DursCore<DuRsConf>) -> Result<(), DursCoreError>,
{
match self.command {
DursCommandEnum::Core(core_cmd) => {
durs_exec_core_cmd!(core_cmd, self.options, plug_modules,)
}
DursCommandEnum::Core(core_cmd) => DursCore::execute_core_command(
core_cmd,
self.options,
vec![],
plug_modules,
soft_name,
soft_version,
),
DursCommandEnum::Other(cmd) => cmd.execute_module_command(self.options),
}
}
......
......@@ -56,21 +56,6 @@ use std::path::PathBuf;
use std::sync::mpsc;
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]
/// Plug modules in durs core
macro_rules! durs_plug {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment