diff --git a/lib/crates/arc-workflows/src/cli/mod.rs b/lib/crates/arc-workflows/src/cli/mod.rs index 78a1cbef2..90e270ff7 100644 --- a/lib/crates/arc-workflows/src/cli/mod.rs +++ b/lib/crates/arc-workflows/src/cli/mod.rs @@ -250,6 +250,16 @@ pub fn format_tokens_human(tokens: i64) -> String { } } +/// Produce a relative path from cwd; falls back to `tilde_path` if not under cwd. +pub fn relative_path(path: &Path) -> String { + if let Ok(cwd) = std::env::current_dir() { + if let Ok(rel) = path.strip_prefix(&cwd) { + return rel.display().to_string(); + } + } + tilde_path(path) +} + /// Shorten an absolute path by replacing the home directory prefix with `~`. pub fn tilde_path(path: &Path) -> String { if let Some(home) = dirs::home_dir() { diff --git a/lib/crates/arc-workflows/src/cli/run.rs b/lib/crates/arc-workflows/src/cli/run.rs index 681fd48b7..6a392d05b 100644 --- a/lib/crates/arc-workflows/src/cli/run.rs +++ b/lib/crates/arc-workflows/src/cli/run.rs @@ -10,7 +10,7 @@ use arc_util::terminal::Styles; use chrono::{Local, Utc}; use tracing::debug; -use super::tilde_path; +use super::{relative_path, tilde_path}; use crate::checkpoint::Checkpoint; use crate::engine::{RunConfig, WorkflowRunEngine}; use crate::event::EventEmitter; @@ -359,6 +359,11 @@ pub async fn run_command( graph.edges.len() )), ); + eprintln!( + "{} {}", + styles.dim.apply_to("Graph:"), + styles.dim.apply_to(relative_path(&dot_path)), + ); let goal = graph.goal(); if !goal.is_empty() { diff --git a/lib/crates/arc-workflows/src/cli/validate.rs b/lib/crates/arc-workflows/src/cli/validate.rs index 06b1548e0..1e46ad1a6 100644 --- a/lib/crates/arc-workflows/src/cli/validate.rs +++ b/lib/crates/arc-workflows/src/cli/validate.rs @@ -4,7 +4,7 @@ use arc_util::terminal::Styles; use crate::validation::Severity; use crate::workflow::prepare_from_file; -use super::{print_diagnostics, ValidateArgs}; +use super::{print_diagnostics, relative_path, ValidateArgs}; /// Parse and validate a workflow file without executing it. /// @@ -22,6 +22,11 @@ pub fn validate_command(args: &ValidateArgs, styles: &Styles) -> anyhow::Result< graph.nodes.len(), graph.edges.len(), ); + eprintln!( + "{} {}", + styles.dim.apply_to("Graph:"), + styles.dim.apply_to(relative_path(&dot_path)), + ); print_diagnostics(&diagnostics, styles);