Skip to content

Commit 6d4931f

Browse files
committed
Fix dag create singular task output
1 parent 7954d02 commit 6d4931f

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/cortex-cli/src/agent_cmd/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
#[cfg(test)]
44
mod tests {
55
use crate::agent_cmd::cli::{CopyArgs, ExportArgs};
6-
use crate::agent_cmd::loader::{
7-
load_builtin_agents, parse_frontmatter, read_file_with_encoding,
8-
};
6+
use crate::agent_cmd::loader::{load_builtin_agents, parse_frontmatter};
97
use crate::agent_cmd::types::AgentMode;
8+
use crate::utils::file::read_file_with_encoding;
109

1110
#[test]
1211
fn test_read_file_with_utf8() {

src/cortex-cli/src/dag_cmd/commands.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ use super::helpers::{
1818
use super::scheduler::DagScheduler;
1919
use super::types::{DagOutputFormat, ExecutionStrategy};
2020

21+
pub(super) fn task_count_label(count: usize) -> String {
22+
if count == 1 {
23+
"1 task".to_string()
24+
} else {
25+
format!("{} tasks", count)
26+
}
27+
}
28+
2129
/// Create a DAG from specification.
2230
pub async fn run_create(args: DagCreateArgs) -> Result<()> {
2331
let spec = load_spec(&args.file)?;
@@ -49,7 +57,11 @@ pub async fn run_create(args: DagCreateArgs) -> Result<()> {
4957

5058
match args.format {
5159
DagOutputFormat::Text => {
52-
print_success(&format!("✓ Created DAG '{}' with {} tasks", id, dag.len()));
60+
print_success(&format!(
61+
"✓ Created DAG '{}' with {}",
62+
id,
63+
task_count_label(dag.len())
64+
));
5365
println!();
5466
print_dag_summary(&dag);
5567
}

src/cortex-cli/src/dag_cmd/tests.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::types::{DagSpecInput, TaskSpecInput};
55
use cortex_agents::task::{DagHydrator, Task, TaskId, TaskSpec};
66
use std::collections::HashMap;
77

8+
use super::commands::task_count_label;
89
use super::executor::TaskExecutor;
910

1011
#[test]
@@ -78,6 +79,12 @@ fn test_dag_creation_with_cycle_detection() {
7879
assert!(result.is_err());
7980
}
8081

82+
#[test]
83+
fn test_dag_create_task_count_label_uses_singular_for_one_task() {
84+
assert_eq!(task_count_label(1), "1 task");
85+
assert_eq!(task_count_label(2), "2 tasks");
86+
}
87+
8188
#[tokio::test]
8289
async fn test_task_executor() {
8390
let executor = TaskExecutor::new(30, false);

0 commit comments

Comments
 (0)