diff --git a/src/crufty/cli.rs b/src/crufty/cli.rs index 6650de8..756a832 100644 --- a/src/crufty/cli.rs +++ b/src/crufty/cli.rs @@ -15,6 +15,8 @@ pub enum Commands { Scan, /// Clean all build artifacts in the current directory Clean, + /// Show all built-in artifact types + ArtifactTypes, } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index 489676a..be847e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,10 @@ fn main() { Err(err) => exit_unrecoverable(err), Ok(_) => {} }, + Commands::ArtifactTypes => match artifact_types() { + Err(err) => exit_unrecoverable(err), + Ok(_) => {} + }, } } @@ -138,6 +142,17 @@ fn clean() -> io::Result<()> { } } +fn artifact_types() -> io::Result<()> { + let term = Term::stdout(); + term.write_line("Built-in artifact types supported by crufty:")?; + for (i, artifact) in artifact_type::builtin().iter_mut().enumerate() { + term.write_line(&format!("[{}] {}", i + 1, artifact.artifact_type_name()))?; + term.write_line(&format!(" - Matches: {}", artifact.pattern()))?; + term.write_line(&format!(" - Recognized by: {}", artifact.recognized_files().join(", ")))?; + } + Ok(()) +} + fn exit_unrecoverable(_err: io::Error) { let term_err = Term::stderr(); let error_message = "Encountered error, existing...";