fix: do not print table if running in daemon mode

This commit is contained in:
binarybaron 2024-07-26 16:36:59 +02:00
parent 7082e8938b
commit a1acbc18fd
No known key found for this signature in database
GPG key ID: 99B75D3E1476A26E
3 changed files with 29 additions and 6 deletions

View file

@ -167,6 +167,7 @@ pub struct Context {
pub swap_lock: Arc<SwapLock>,
pub config: Config,
pub tasks: Arc<PendingTaskList>,
pub is_daemon: bool,
}
#[allow(clippy::too_many_arguments)]
@ -180,6 +181,7 @@ impl Context {
debug: bool,
json: bool,
server_address: Option<SocketAddr>,
is_daemon: bool,
) -> Result<Context> {
let data_dir = data::data_dir_from(data, is_testnet)?;
let env_config = env_config_from(is_testnet);
@ -241,6 +243,7 @@ impl Context {
},
swap_lock: Arc::new(SwapLock::new()),
tasks: Arc::new(PendingTaskList::default()),
is_daemon,
};
Ok(context)
@ -265,6 +268,7 @@ impl Context {
monero_rpc_process: None,
swap_lock: Arc::new(SwapLock::new()),
tasks: Arc::new(PendingTaskList::default()),
is_daemon: true,
}
}

View file

@ -727,7 +727,7 @@ impl Request {
}
}
if !context.config.json {
if !context.config.json && !context.is_daemon {
println!("{}", table);
}

View file

@ -78,6 +78,7 @@ where
debug,
json,
None,
false,
)
.await?;
@ -100,14 +101,16 @@ where
let request = Request::new(Method::History);
let context =
Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
Context::build(None, None, None, data, is_testnet, debug, json, None, false)
.await?;
(context, request)
}
CliCommand::Config => {
let request = Request::new(Method::Config);
let context =
Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
Context::build(None, None, None, data, is_testnet, debug, json, None, false)
.await?;
(context, request)
}
CliCommand::Balance { bitcoin } => {
@ -124,6 +127,7 @@ where
debug,
json,
None,
false,
)
.await?;
(context, request)
@ -145,6 +149,7 @@ where
debug,
json,
server_address,
true,
)
.await?;
(context, request)
@ -166,6 +171,7 @@ where
debug,
json,
None,
false,
)
.await?;
(context, request)
@ -207,6 +213,7 @@ where
debug,
json,
None,
false,
)
.await?;
(context, request)
@ -217,8 +224,18 @@ where
} => {
let request = Request::new(Method::ListSellers { rendezvous_point });
let context =
Context::build(None, None, Some(tor), data, is_testnet, debug, json, None).await?;
let context = Context::build(
None,
None,
Some(tor),
data,
is_testnet,
debug,
json,
None,
false,
)
.await?;
(context, request)
}
@ -234,6 +251,7 @@ where
debug,
json,
None,
false,
)
.await?;
(context, request)
@ -244,7 +262,8 @@ where
let request = Request::new(Method::MoneroRecovery { swap_id });
let context =
Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
Context::build(None, None, None, data, is_testnet, debug, json, None, false)
.await?;
(context, request)
}