Skip to content

Commit

Permalink
Merge pull request #7 from omarahm3/feat/more-colors
Browse files Browse the repository at this point in the history
feat(config): colorize config output
  • Loading branch information
omarahm3 authored Dec 26, 2021
2 parents b4e00fe + 8e321cd commit c2a102e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version ="1.57"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
colored = "2.0.0"
dirs = "4.0.0"
serde = { version = "1.0.132", features = ["derive"] }
serde_json = "1.0.73"
11 changes: 6 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fs;
use std::io::prelude::*;
use std::path::Path;
use std::path::PathBuf;
use colored::*;

const CONFIG_INIT: &str = r#"
{
Expand Down Expand Up @@ -83,15 +84,15 @@ pub fn print(program: ProgramInfo) {
};
let detail = args.iter().any(|arg| arg == "--detail" || arg == "-d");

println!("Config path: [{}]", path);
println!("Projects:");
println!("{}: [{}]", "Config path".bold(), path);
println!("{}:", "Projects".bold());
for project in projects.iter() {
let path = match project.path.to_str() {
None => "N/A",
Some(path) => path,
};
println!("\t{}\t\t{}", project.name, path);
println!("\tRepositories");
println!("\t{}\t\t{}", project.name.underline(), path);
println!("\t{}", "Repositories".underline());

for repository in project.repositories.iter() {
let path = repository.clone();
Expand All @@ -109,7 +110,7 @@ pub fn print(program: ProgramInfo) {
if detail {
let current_branch = git_current_branch(repository.to_path_buf());
// TODO properly handle the perfect alignment of the tabs
println!(" \t\t-> {}", current_branch);
println!(" ({})", current_branch.yellow());
} else {
println!();
}
Expand Down

0 comments on commit c2a102e

Please sign in to comment.