Skip to content

Commit e66d83c

Browse files
marekklisEncodePanda
authored andcommitted
Add artifact-types parameter
1 parent e5da81a commit e66d83c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/crufty/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub enum Commands {
1515
Scan,
1616
/// Clean all build artifacts in the current directory
1717
Clean,
18+
/// Show all built-in artifact types
19+
ArtifactTypes,
1820
}
1921

2022
#[cfg(test)]

src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ fn main() {
2525
Err(err) => exit_unrecoverable(err),
2626
Ok(_) => {}
2727
},
28+
Commands::ArtifactTypes => match artifact_types() {
29+
Err(err) => exit_unrecoverable(err),
30+
Ok(_) => {}
31+
},
2832
}
2933
}
3034

@@ -138,6 +142,17 @@ fn clean() -> io::Result<()> {
138142
}
139143
}
140144

145+
fn artifact_types() -> io::Result<()> {
146+
let term = Term::stdout();
147+
term.write_line("Built-in artifact types supported by crufty:")?;
148+
for (i, artifact) in artifact_type::builtin().iter_mut().enumerate() {
149+
term.write_line(&format!("[{}] {}", i + 1, artifact.artifact_type_name()))?;
150+
term.write_line(&format!(" - Matches: {}", artifact.pattern()))?;
151+
term.write_line(&format!(" - Recognized by: {}", artifact.recognized_files().join(", ")))?;
152+
}
153+
Ok(())
154+
}
155+
141156
fn exit_unrecoverable(_err: io::Error) {
142157
let term_err = Term::stderr();
143158
let error_message = "Encountered error, existing...";

0 commit comments

Comments
 (0)