mirror of
https://github.com/casey/just.git
synced 2024-11-27 09:15:08 +03:00
Omit aliases that begin with _
from --list` (#398)
This commit is contained in:
parent
3a287b864a
commit
e118051a5c
@ -608,7 +608,7 @@ Run `just --help` to see all the options.
|
|||||||
|
|
||||||
=== Private Recipes
|
=== Private Recipes
|
||||||
|
|
||||||
Recipes whose name starts with a `_` are omitted from `just --list`:
|
Recipes and aliases whose name starts with a `_` are omitted from `just --list`:
|
||||||
|
|
||||||
```make
|
```make
|
||||||
test: _test-helper
|
test: _test-helper
|
||||||
|
@ -4,6 +4,7 @@ pub struct Alias<'a> {
|
|||||||
pub name: &'a str,
|
pub name: &'a str,
|
||||||
pub target: &'a str,
|
pub target: &'a str,
|
||||||
pub line_number: usize,
|
pub line_number: usize,
|
||||||
|
pub private: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Display for Alias<'a> {
|
impl<'a> Display for Alias<'a> {
|
||||||
|
@ -372,6 +372,7 @@ impl<'a> Parser<'a> {
|
|||||||
Alias {
|
Alias {
|
||||||
name: name.lexeme,
|
name: name.lexeme,
|
||||||
line_number: name.line,
|
line_number: name.line,
|
||||||
|
private: name.lexeme.starts_with('_'),
|
||||||
target,
|
target,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -358,6 +358,10 @@ pub fn run() {
|
|||||||
// Construct a target to alias map.
|
// Construct a target to alias map.
|
||||||
let mut recipe_aliases: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
|
let mut recipe_aliases: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
|
||||||
for alias in justfile.aliases.values() {
|
for alias in justfile.aliases.values() {
|
||||||
|
if alias.private {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if !recipe_aliases.contains_key(alias.target) {
|
if !recipe_aliases.contains_key(alias.target) {
|
||||||
recipe_aliases.insert(alias.target, vec![alias.name]);
|
recipe_aliases.insert(alias.target, vec![alias.name]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,6 +132,17 @@ integration_test! {
|
|||||||
status: EXIT_SUCCESS,
|
status: EXIT_SUCCESS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
integration_test! {
|
||||||
|
name: alias_listing_private,
|
||||||
|
justfile: "foo PARAM='foo':\n echo {{PARAM}}\nalias _f = foo",
|
||||||
|
args: ("--list"),
|
||||||
|
stdout: "Available recipes:
|
||||||
|
foo PARAM='foo'
|
||||||
|
",
|
||||||
|
stderr: "",
|
||||||
|
status: EXIT_SUCCESS,
|
||||||
|
}
|
||||||
|
|
||||||
integration_test! {
|
integration_test! {
|
||||||
name: alias,
|
name: alias,
|
||||||
justfile: "foo:\n echo foo\nalias f = foo",
|
justfile: "foo:\n echo foo\nalias f = foo",
|
||||||
|
Loading…
Reference in New Issue
Block a user