Skip to content

Commit

Permalink
fix(CLI): Remove flag gates; implement plain display
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed May 16, 2021
1 parent baaa2d3 commit 37a9c66
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ pub async fn main() -> Result<()> {
let mut projects = projects::Projects::default();

// If not explicitly upgrading then run an upgrade check in the background
#[cfg(feature = "upgrade")]
let upgrade_thread = if let Some(Command::Upgrade(_)) = command {
None
} else {
Expand Down Expand Up @@ -266,7 +265,6 @@ pub async fn main() -> Result<()> {
};

// Join the upgrade thread and log any errors
#[cfg(feature = "upgrade")]
if let Some(upgrade_thread) = upgrade_thread {
if let Err(_error) = upgrade_thread.join() {
tracing::warn!("Error while attempting to join upgrade thread")
Expand Down Expand Up @@ -373,26 +371,24 @@ mod feedback {
mod display {
use super::*;

pub fn display(what: Option<(String, String)>) -> Result<()> {
let (format, content) = match &what {
None => return Ok(()),
Some(pair) => pair,
};

match format.as_str() {
"md" => render(format, content),
_ => highlight(format, content),
// Display the result of a command prettily
pub fn display(result: Option<(String, String)>) -> Result<()> {
if let Some((format, content)) = result {
match format.as_str() {
"md" => render(&format, &content),
_ => highlight(&format, &content),
}
}

Ok(())
}

//
// Render Markdown to the terminal
pub fn render(_format: &str, content: &str) {
let skin = termimad::MadSkin::default();
println!("{}", skin.term_text(content))
}

// Apply syntax highlighting and print to terminal
pub fn highlight(format: &str, content: &str) {
use syntect::easy::HighlightLines;
use syntect::highlighting::{Style, ThemeSet};
Expand Down Expand Up @@ -421,9 +417,11 @@ mod display {
mod display {
use super::*;

pub fn display(what: (String, String)) -> Result<()> {
let (_format, content) = what;
println!("{}", content);
// Display the result of a command without prettiness
pub fn display(result: Option<(String, String)>) -> Result<()> {
if let Some((_format, content)) = result {
println!("{}", content);
}
Ok(())
}
}
Expand Down

0 comments on commit 37a9c66

Please sign in to comment.