Skip to content

Commit

Permalink
Rename Justfile::first → Justfile::default (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Nov 22, 2023
1 parent ab16c04 commit 09a3905
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'src> Analyzer<'src> {
let root = paths.get(root).unwrap();

Ok(Justfile {
first: recipes
default: recipes
.values()
.filter(|recipe| recipe.name.path == root)
.fold(None, |accumulator, next| match accumulator {
Expand Down
9 changes: 2 additions & 7 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ impl Compiler {
loader: &'src Loader,
root: &Path,
) -> RunResult<'src, Compilation<'src>> {
let mut srcs: HashMap<PathBuf, &str> = HashMap::new();
let mut asts: HashMap<PathBuf, Ast> = HashMap::new();
let mut paths: HashMap<PathBuf, PathBuf> = HashMap::new();
let mut srcs: HashMap<PathBuf, &str> = HashMap::new();

let mut stack: Vec<PathBuf> = Vec::new();
stack.push(root.into());

while let Some(current) = stack.pop() {
let (relative, src) = loader.load(root, &current)?;
paths.insert(current.clone(), relative.into());

let tokens = Lexer::lex(relative, src)?;
let mut ast = Parser::parse(&tokens)?;

paths.insert(current.clone(), relative.into());
srcs.insert(current.clone(), src);

for item in &mut ast.items {
Expand All @@ -31,15 +30,11 @@ impl Compiler {
message: "The !include directive is currently unstable.".into(),
});
}

let include = current.parent().unwrap().join(relative).lexiclean();

if srcs.contains_key(&include) {
return Err(Error::CircularInclude { current, include });
}

*absolute = Some(include.clone());

stack.push(include);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use {super::*, serde::Serialize};
pub(crate) struct Justfile<'src> {
pub(crate) aliases: Table<'src, Alias<'src>>,
pub(crate) assignments: Table<'src, Assignment<'src>>,
#[serde(serialize_with = "keyed::serialize_option")]
pub(crate) first: Option<Rc<Recipe<'src>>>,
#[serde(rename = "first", serialize_with = "keyed::serialize_option")]
pub(crate) default: Option<Rc<Recipe<'src>>>,
pub(crate) recipes: Table<'src, Rc<Recipe<'src>>>,
pub(crate) settings: Settings<'src>,
pub(crate) warnings: Vec<Warning>,
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'src> Justfile<'src> {

let argvec: Vec<&str> = if !arguments.is_empty() {
arguments.iter().map(String::as_str).collect()
} else if let Some(recipe) = &self.first {
} else if let Some(recipe) = &self.default {
let min_arguments = recipe.min_arguments();
if min_arguments > 0 {
return Err(Error::DefaultRecipeRequiresArguments {
Expand Down

0 comments on commit 09a3905

Please sign in to comment.