feat: add color to info
This commit is contained in:
@@ -20,5 +20,4 @@ walkdir = "2.5.0"
|
||||
minijinja = "2.7.0"
|
||||
glob = "0.3.2"
|
||||
serde_json = "1.0.138"
|
||||
syntect = "5.2.0"
|
||||
syntect-assets = "0.23.6"
|
||||
colored_json = "5.0.0"
|
||||
|
@@ -1,15 +1,9 @@
|
||||
use std::{net::SocketAddr, path::PathBuf};
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use colored_json::ToColoredJson;
|
||||
use kdl::KdlDocument;
|
||||
use rusty_s3::{Bucket, Credentials, S3Action};
|
||||
use syntect::{
|
||||
easy::HighlightLines,
|
||||
highlighting::{Style, ThemeSet},
|
||||
parsing::SyntaxSet,
|
||||
util::{as_24_bit_terminal_escaped, LinesWithEndings},
|
||||
};
|
||||
use syntect_assets::assets::HighlightingAssets;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
use crate::{
|
||||
@@ -104,19 +98,7 @@ pub async fn execute() -> anyhow::Result<()> {
|
||||
|
||||
Commands::Info {} => {
|
||||
let output = serde_json::to_string_pretty(&context)?;
|
||||
let assets = HighlightingAssets::from_binary();
|
||||
let theme = assets.get_theme("OneHalfDark");
|
||||
|
||||
let ss = SyntaxSet::load_defaults_nonewlines();
|
||||
|
||||
let syntax = ss.find_syntax_by_extension("json").unwrap();
|
||||
let mut h = HighlightLines::new(syntax, theme);
|
||||
|
||||
for line in LinesWithEndings::from(&output) {
|
||||
let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ss).unwrap();
|
||||
print!("{}", as_24_bit_terminal_escaped(&ranges[..], true));
|
||||
}
|
||||
println!()
|
||||
println!("{}", output.to_colored_json_auto().unwrap_or(output));
|
||||
}
|
||||
|
||||
Commands::Template {} => {
|
||||
|
Reference in New Issue
Block a user