Skip to content

Commit

Permalink
Hide recipes with names starting with an _ from --list and --sumamary (
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Oct 7, 2017
1 parent a07fc22 commit 8fa91a4
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 69 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [Unreleased]

## [0.3.1] - 2017-10-06
### Added
- Started keeping a changelog in CHANGELOG.md
- Recipes whose names begin with an underscore will not appear in `--list` or `--summary`
134 changes: 69 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "just"
version = "0.3.0"
version = "0.3.1"
description = "🤖 Just a command runner"
authors = ["Casey Rodarmor <[email protected]>"]
license = "WTFPL OR MIT OR Apache-2.0"
Expand Down
11 changes: 10 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,13 @@ pub fn app() {
if justfile.count() == 0 {
eprintln!("Justfile contains no recipes.");
} else {
println!("{}", justfile.recipes.keys().cloned().collect::<Vec<_>>().join(" "));
let summary = justfile.recipes.iter()
.filter(|&(_, recipe)| !recipe.private)
.map(|(name, _)| name)
.cloned()
.collect::<Vec<_>>()
.join(" ");
println!("{}", summary);
}
process::exit(EXIT_SUCCESS);
}
Expand All @@ -246,6 +252,9 @@ pub fn app() {
let doc_color = color.stdout().doc();
println!("Available recipes:");
for (name, recipe) in &justfile.recipes {
if recipe.private {
continue;
}
print!(" {}", name);
for parameter in &recipe.parameters {
if color.stdout().active() {
Expand Down
8 changes: 7 additions & 1 deletion src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ integration_test! {
justfile: "b: a
a:
d: c
c: b",
c: b
_z: _y
_y:
",
args: ("--summary"),
stdout: "a b c d\n",
stderr: "",
Expand Down Expand Up @@ -1020,6 +1023,9 @@ hello a b='B ' c='C':
# this comment will be ignored
a Z="\t z":
# this recipe will not appear
_private-recipe:
"#,
args: ("--list"),
stdout: r"Available recipes:
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct Recipe<'a> {
lines: Vec<Vec<Fragment<'a>>>,
name: &'a str,
parameters: Vec<Parameter<'a>>,
private: bool,
quiet: bool,
shebang: bool,
}
Expand Down Expand Up @@ -2015,6 +2016,7 @@ impl<'a> Parser<'a> {
dependencies: dependencies,
dependency_tokens: dependency_tokens,
parameters: parameters,
private: &name.lexeme[0..1] == "_",
lines: lines,
shebang: shebang,
quiet: quiet,
Expand Down

0 comments on commit 8fa91a4

Please sign in to comment.