Skip to content

Commit 23d2f19

Browse files
committed
Add CLI flag
1 parent 3fdb0c7 commit 23d2f19

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ enum Command {
2121
#[clap(about = "Finds the owner of a given file.", visible_alias = "f")]
2222
ForFile { name: String },
2323

24+
#[clap(about = "Finds code ownership information for a given team ", visible_alias = "t")]
25+
ForTeam { name: String },
26+
2427
#[clap(
2528
about = "Generate the CODEOWNERS file and save it to '--codeowners-file-path'.",
2629
visible_alias = "g"
@@ -135,6 +138,9 @@ fn cli() -> Result<(), Error> {
135138
}
136139
}
137140
}
141+
Command::ForTeam { name } => {
142+
println!("Team: {name}")
143+
}
138144
}
139145

140146
Ok(())

tests/valid_project_test.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ fn test_for_file() -> Result<(), Box<dyn Error>> {
4747

4848
Ok(())
4949
}
50+
51+
#[test]
52+
fn test_for_team() -> Result<(), Box<dyn Error>> {
53+
Command::cargo_bin("codeowners")?
54+
.arg("--project-root")
55+
.arg("tests/fixtures/valid_project")
56+
.arg("for-team")
57+
.arg("Payroll")
58+
.assert()
59+
.success()
60+
.stdout(predicate::str::contains("Team: Payroll"));
61+
62+
Ok(())
63+
}

0 commit comments

Comments
 (0)