aboutsummaryrefslogtreecommitdiff
path: root/src/output.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/output.rs')
-rw-r--r--src/output.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/output.rs b/src/output.rs
index 2a2546f..f6e9bc4 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -1,3 +1,4 @@
+//! Functions for console output.
use super::{
api,
bt::{BuildTemplate, Traitline},
@@ -7,6 +8,9 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
const HEADER_COLOR: Color = Color::Cyan;
+/// Format a skill for displaying.
+///
+/// This is just the skill name (if given).
fn format_skill(skill: &Option<api::Skill>) -> String {
match *skill {
None => "none".to_owned(),
@@ -14,6 +18,7 @@ fn format_skill(skill: &Option<api::Skill>) -> String {
}
}
+/// Format a traitline for displaying.
fn format_traitline(traitline: &Option<Traitline>) -> String {
match *traitline {
None => "none".to_owned(),
@@ -24,6 +29,7 @@ fn format_traitline(traitline: &Option<Traitline>) -> String {
}
}
+/// Show a build template to the standard output stream.
pub fn show_build_template(build: &BuildTemplate) -> io::Result<()> {
let mut stdout = StandardStream::stdout(ColorChoice::Auto);
let mut color_spec = ColorSpec::new();
@@ -58,6 +64,9 @@ pub fn show_build_template(build: &BuildTemplate) -> io::Result<()> {
Ok(())
}
+/// Show an error to the standard error stream.
+///
+/// This will also show the chain of errors that lead up to this error, if available.
pub fn show_error<E: Error + ?Sized>(error: &E) -> io::Result<()> {
let mut error_color = ColorSpec::new();
error_color.set_fg(Some(Color::Red));