Skip to content

Commit

Permalink
More list stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Jan 13, 2024
1 parent 82effcb commit 90a400c
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/list_recipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,21 @@ fn get_line_widths<'a>(
line_widths
}

fn print_recipe(recipe: &Recipe, aliases: &Vec<&str>) {}

fn print_doc_comment(doc: &str, padding: usize, doc_color: Color) {
print!(
" {:padding$}{} {}",
"",
doc_color.paint("#"),
doc_color.paint(doc),
padding = padding
);
}

pub(crate) fn list(config: &Config, level: usize, justfile: &Justfile) {
if config.groups {
println!("GROUPS palceholder");
print!("GROUPS palceholder");
return;
}

Expand All @@ -65,20 +77,9 @@ pub(crate) fn list(config: &Config, level: usize, justfile: &Justfile) {
let doc_color = config.color.stdout().doc();

if level == 0 {
println!("{}", config.list_heading);
print!("{}", config.list_heading);
}

let print_doc = |doc: &str, name: &str| {
print!(
" {:padding$}{} {}",
"",
doc_color.paint("#"),
doc_color.paint(doc),
padding =
max_line_width.saturating_sub(line_widths.get(name).copied().unwrap_or(max_line_width))
);
};

for recipe in justfile.public_recipes(config.unsorted) {
let name = recipe.name();

Expand All @@ -91,12 +92,14 @@ pub(crate) fn list(config: &Config, level: usize, justfile: &Justfile) {
print!(" {}", parameter.color_display(config.color.stdout()));
}

let padding =
max_line_width.saturating_sub(line_widths.get(name).copied().unwrap_or(max_line_width));
match (i, recipe.doc) {
(0, Some(doc)) => print_doc(doc, name),
(0, Some(doc)) => print_doc_comment(&doc, padding, doc_color),
(0, None) => (),
_ => {
let alias_doc = format!("alias for `{}`", recipe.name);
print_doc(&alias_doc, name);
print_doc_comment(&alias_doc, padding, doc_color);
}
}
println!();
Expand Down

0 comments on commit 90a400c

Please sign in to comment.