-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix submodule recipe listing indentation (#2063)
- Loading branch information
Showing
6 changed files
with
135 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use super::*; | ||
|
||
pub(crate) struct RecipeSignature<'a> { | ||
pub(crate) name: &'a str, | ||
pub(crate) recipe: &'a Recipe<'a>, | ||
} | ||
|
||
impl<'a> ColorDisplay for RecipeSignature<'a> { | ||
fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result { | ||
write!(f, "{}", self.name)?; | ||
for parameter in &self.recipe.parameters { | ||
write!(f, " {}", parameter.color_display(color))?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use super::*; | ||
|
||
#[test] | ||
fn list_displays_recipes_in_submodules() { | ||
Test::new() | ||
.write("foo.just", "bar:\n @echo FOO") | ||
.justfile( | ||
" | ||
mod foo | ||
", | ||
) | ||
.test_round_trip(false) | ||
.arg("--unstable") | ||
.arg("--list") | ||
.stdout( | ||
" | ||
Available recipes: | ||
foo: | ||
bar | ||
", | ||
) | ||
.run(); | ||
} | ||
|
||
#[test] | ||
fn module_recipe_list_alignment_ignores_private_recipes() { | ||
Test::new() | ||
.write( | ||
"foo.just", | ||
" | ||
# foos | ||
foo: | ||
@echo FOO | ||
[private] | ||
barbarbar: | ||
@echo BAR | ||
@_bazbazbaz: | ||
@echo BAZ | ||
", | ||
) | ||
.justfile("mod foo") | ||
.test_round_trip(false) | ||
.arg("--unstable") | ||
.arg("--list") | ||
.stdout( | ||
" | ||
Available recipes: | ||
foo: | ||
foo # foos | ||
", | ||
) | ||
.run(); | ||
} | ||
|
||
#[test] | ||
fn nested_modules_are_properly_indented() { | ||
Test::new() | ||
.write("foo.just", "mod bar") | ||
.write("bar.just", "baz:\n @echo FOO") | ||
.justfile( | ||
" | ||
mod foo | ||
", | ||
) | ||
.test_round_trip(false) | ||
.arg("--unstable") | ||
.arg("--list") | ||
.stdout( | ||
" | ||
Available recipes: | ||
foo: | ||
bar: | ||
baz | ||
", | ||
) | ||
.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters