Skip to content

Commit

Permalink
by-groups listing infra
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Jan 14, 2024
1 parent 4406c08 commit c440b75
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
15 changes: 1 addition & 14 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,20 +497,7 @@ impl<'src> Justfile<'src> {
.values()
.map(AsRef::as_ref)
.filter(|recipe| recipe.is_public())
.flat_map(|recipe| {
recipe.groups()
/*
//TODO this should use a .groups() method
let groups = recipe.attributes.iter().filter_map(|attr| {
if let Attribute::Group { name } = attr {
Some(*name)
} else {
None
}
});
groups
*/
})
.flat_map(|recipe| recipe.groups())
.collect()
}
}
Expand Down
23 changes: 18 additions & 5 deletions src/list_recipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,25 @@ pub(crate) fn list(config: &Config, level: usize, justfile: &Justfile) {
}

let public_recipes = justfile.public_recipes(config.unsorted);
/*
let mut by_groups = HashMap::new();
for recipe in public_recipes {
let mut by_groups: HashMap<Option<&str>, Vec<&str>> = HashMap::new();

for recipe in &public_recipes {
let recipe_name = recipe.name();
let groups = recipe.groups();
if groups.is_empty() {
by_groups
.entry(None)
.and_modify(|e| e.push(recipe_name))
.or_insert(vec![recipe_name]);
} else {
for group in groups {
by_groups
.entry(Some(group))
.and_modify(|e| e.push(recipe_name))
.or_insert(vec![recipe_name]);
}
}
}
*/

for recipe in public_recipes {
let aliases: &[&str] = recipe_aliases
Expand Down
2 changes: 1 addition & 1 deletion src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<'src, D> Recipe<'src, D> {

pub(crate) fn groups(&self) -> HashSet<&str> {
let mut groups = HashSet::new();
for attr in self.attributes.iter() {
for attr in &self.attributes {
if let Attribute::Group { name } = attr {
groups.insert(name.as_ref());
}
Expand Down

0 comments on commit c440b75

Please sign in to comment.