Omit aliases that begin with _ from --list` (#398)

This commit is contained in:
Casey Rodarmor 2019-04-11 15:57:34 -07:00 committed by GitHub
parent 3a287b864a
commit e118051a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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> {

View File

@ -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,
}, },
); );

View File

@ -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 {

View File

@ -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",