Skip to content

feat(tasks): make script task dirs configurable#1571

Merged
jdx merged 1 commit intojdx:mainfrom
Ajpantuso:apantuso/configure_task_dir
Jan 31, 2024
Merged

feat(tasks): make script task dirs configurable#1571
jdx merged 1 commit intojdx:mainfrom
Ajpantuso:apantuso/configure_task_dir

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.

@Ajpantuso Ajpantuso force-pushed the apantuso/configure_task_dir branch from 774ce00 to c0901bc Compare January 31, 2024 16:38
#[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.

@Ajpantuso Ajpantuso force-pushed the apantuso/configure_task_dir branch from c0901bc to 1670484 Compare January 31, 2024 19:47
@Ajpantuso Ajpantuso force-pushed the apantuso/configure_task_dir branch from 1670484 to 5f50669 Compare January 31, 2024 19:58
@jdx jdx merged commit 90c35ab into jdx:main Jan 31, 2024
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
jdx pushed a commit that referenced this pull request Aug 31, 2025
Resolves #6151.

I read the implementation and confirmed it overrode the default.
It seems it's the intended behaviour since the initial PR
#1571.
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