Warn when no outputs enabled for session command

This commit is contained in:
Marcin Kulik
2025-04-15 15:13:05 +02:00
parent 4aced695d6
commit b0a75ae52d
2 changed files with 23 additions and 7 deletions

View File

@@ -113,10 +113,6 @@ impl cli::Session {
status::info!("Live streaming at {}", url);
}
if command.is_none() {
status::info!("Press <ctrl+d> or type 'exit' to end");
}
let stream = Stream::new();
let shutdown_token = CancellationToken::new();
@@ -148,6 +144,14 @@ impl cli::Session {
outputs.push(Box::new(output));
}
if outputs.is_empty() {
status::warning!("No outputs enabled, consider using -o, -s, or -r");
}
if command.is_none() {
status::info!("Press <ctrl+d> or type 'exit' to end");
}
let exec_command = build_exec_command(command.as_ref().cloned());
let exec_extra_env = build_exec_extra_env(relay_id.as_ref());

View File

@@ -6,14 +6,26 @@ pub fn disable() {
}
macro_rules! info {
($fmt:expr) => (crate::status::println(format!($fmt)));
($fmt:expr, $($arg:tt)*) => (crate::status::println(format!($fmt, $($arg)*)));
($fmt:expr) => (crate::status::do_info(format!($fmt)));
($fmt:expr, $($arg:tt)*) => (crate::status::do_info(format!($fmt, $($arg)*)));
}
pub fn println(message: String) {
macro_rules! warning {
($fmt:expr) => (crate::status::do_warn(format!($fmt)));
($fmt:expr, $($arg:tt)*) => (crate::status::do_warn(format!($fmt, $($arg)*)));
}
pub fn do_info(message: String) {
if ENABLED.load(SeqCst) {
println!("::: {message}");
}
}
pub fn do_warn(message: String) {
if ENABLED.load(SeqCst) {
println!("!!! {message}");
}
}
pub(crate) use info;
pub(crate) use warning;