diff --git a/binaries/cli/src/main.rs b/binaries/cli/src/main.rs index ab6383bfe..4b25cbddd 100644 --- a/binaries/cli/src/main.rs +++ b/binaries/cli/src/main.rs @@ -90,7 +90,10 @@ enum Command { // Planned for future releases: // Dashboard, /// Show logs of a given dataflow and node. - Logs { dataflow: String, node: String }, + Logs { + dataflow_or_node: String, + node: Option, + }, // Metrics, // Stats, // Get, @@ -191,12 +194,29 @@ fn run() -> eyre::Result<()> { internal_create_with_path_dependencies, } => template::create(args, internal_create_with_path_dependencies)?, Command::Up { config } => up::up(config.as_deref())?, - Command::Logs { dataflow, node } => { - let uuid = Uuid::parse_str(&dataflow).ok(); - let name = if uuid.is_some() { None } else { Some(dataflow) }; + + Command::Logs { + dataflow_or_node, + node, + } => { let mut session = connect_to_coordinator().wrap_err("failed to connect to dora coordinator")?; - logs::logs(&mut *session, uuid, name, node)? + let uuids = query_running_dataflows(&mut *session) + .wrap_err("failed to query running dataflows")?; + if let Some(node) = node { + let dataflow = dataflow_or_node; + let uuid = Uuid::parse_str(&dataflow).ok(); + let name = if uuid.is_some() { None } else { Some(dataflow) }; + logs::logs(&mut *session, uuid, name, node)? + } else { + let uuid = match &uuids[..] { + [] => bail!("No dataflows are running"), + [uuid] => uuid.clone(), + _ => inquire::Select::new("Choose dataflow to show logs:", uuids).prompt()?, + }; + let node = dataflow_or_node; + logs::logs(&mut *session, Some(uuid.uuid), None, node)? + } } Command::Start { dataflow,