From 6f8d3514c644fefb717e7b66652e53af61168bb5 Mon Sep 17 00:00:00 2001 From: Rami Daghlawi Date: Sat, 3 Sep 2022 02:06:51 +0200 Subject: [PATCH] printing current working path --- src/commands.rs | 19 +++++++++++++++++++ src/main.rs | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index ef38056..8dbbf32 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,12 +4,31 @@ use std::process::{Child, Command, Stdio}; #[allow(dead_code)] pub fn print_themes() { let printer = PrettyPrinter::new(); + + println!("Syntaxes:"); + for syntax in printer.syntaxes() { + println!("- {} ({})", syntax.name, syntax.file_extensions.join(", ")); + } + + println!(); + println!("Themes:"); for theme in printer.themes() { println!("- {}", theme); } } +pub fn pretty_print_path(string: String) { + PrettyPrinter::new() + .input(Input::from_bytes(&string.as_bytes())) + .header(true) + .grid(true) + .language("syslog") + .theme("OneHalfDark") + .print() + .unwrap(); +} + pub fn pretty_print(string: String) { PrettyPrinter::new() .input( diff --git a/src/main.rs b/src/main.rs index 49f774d..60feab8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ mod commands; mod settings; use clap::Parser; -use commands::{get_build, get_diff, pretty_print}; +use commands::{get_build, get_diff, pretty_print, pretty_print_path}; use serde::Deserialize; use serde_yaml::Value; use settings::Settings; @@ -18,10 +18,13 @@ pub struct Cli { fn main() -> Result<(), io::Error> { let args = Cli::parse(); let mut settings = Settings::load()?; + settings.configs.env = args.env.unwrap_or_default(); let entry = Settings::get_service_paths(&settings)?; for path in entry { + pretty_print_path(format!("Path: {}", path.to_string())); + let build = get_build(&path); for document in serde_yaml::Deserializer::from_str(build.as_str()) { let v = Value::deserialize(document).unwrap();