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(tasks): make script task dirs configurable #1571

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

Ajpantuso
Copy link
Contributor

Summary

Closes #1270

Adds a top-level config Table, task_config, which currently has one property includes. includes is an array of paths which can be used to alter the locations from which file tasks are loaded from.

These paths can be absolute, relative, inside/outside the project, and accepts ~ as a substitution for $HOME.

Additional Notes

  • includes is represented as a BTreeSet to preserve ordering, allows users to influence load ordering, and to ensure uniqueness.

@@ -50,6 +50,8 @@ pub struct MiseToml {
#[serde(default)]
plugins: HashMap<String, String>,
#[serde(skip)]
pub task_config: TaskConfig,
Copy link
Owner

Choose a reason for hiding this comment

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

can you change this to parse via derive? I'm trying to get rid of the manual parsing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what I actually started with, but didn't quite understand how templates are being rendered to the deserialized values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm, I see now. Was looking in the wrong place.

fn parse_template(
&self,
ctx: &tera::Context,
path: &Path,
input: &str,
) -> eyre::Result<String> {
if !input.contains("{{") && !input.contains("{%") && !input.contains("{#") {
return Ok(input.to_string());
}
trust_check(path)?;
let dir = path.parent();
let output = get_tera(dir)
.render_str(input, ctx)
.wrap_err_with(|| eyre!("failed to parse template: '{input}'"))?;
Ok(output)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just dropping support for templating in includes for now. It just adds too much noise for the moment and will be simpler to incorporate after custom parsing is gone.

@jdx jdx merged commit 90c35ab into jdx:main Jan 31, 2024
6 checks passed
jdx added a commit that referenced this pull request Jan 31, 2024
jdx added a commit that referenced this pull request Jan 31, 2024
@Ajpantuso Ajpantuso deleted the apantuso/configure_task_dir branch January 31, 2024 21:29
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.

change task directory
2 participants