Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add working-directory attribute #2438

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bcheidemann
Copy link

Closes #2082

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, see comments!

src/recipe.rs Outdated
}

let working_dir = self
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better implemented as a for loop:

let working_directory = context.working_directory();

for attribute in self.attributes {
  if let Attribute::WorkingDirectory(dir) = attribute {
    return Some(working_directory.join(dir.cooked);
  }
}

Some(working_directory)

Also note the use of cooked, which is the contents of the string literal after processing escape sequences.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better implemented as a for loop

Yup, the suggested for loop reads better and is more concise. Just curious, is there any other reason you suggested this refactor?

Also note the use of cooked, which is the contents of the string literal after processing escape sequences.

Good to know - thanks for the info!

echo "$(basename "$PWD")"

[working-directory('bar')]
[working-directory('baz')]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate working directory attributes should be an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add [cd(DIR)] attribute
2 participants