From 0b1e3ee299fd0eae0d85637fb469934743bc7c38 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Thu, 10 Feb 2022 08:56:27 -0600 Subject: Add support for recursive variables (#44) * Use `self` in pyproject * Add support for recursive variables * Remove duplicate psutil from pyproject * Tweak implementation based on issue feedback * Add type hint to vars_dict * Use `count_of_previously_resolved_vars` name * Clarify test name * Revert refactor and use tuple for variable type return * Add non recursive variable test case * Alter test case name * Add recursive variable docs * Add recursive variables to table of contents * Use PyProject to access static methods * Add better handling of invalid variables * Fix lockfile hash * Move variable import * Only resolve variables once if we are using vars * Fix minor type issue * Reword error message --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 5a955d4..d15a76c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ - [Using Variables](#using-variables) - [String Formatting](#string-formatting) - [Always Use Variables](#always-use-variables) + - [Recursive Variables](#recursive-variables) - [Using Taskipy Without Poetry](#using-taskipy-without-poetry) - [Installing With PIP](#installing-with-pip) - [Running Tasks](#running-tasks-1) @@ -258,6 +259,24 @@ lint = "pylint {path}" black = "black {path}" ``` +#### Recursive Variables + +If we want to use variables within other variables, we can utilize recursive variables. By default, variables are not recursive, but we can specify a variable to be recursive by setting the `recursive` key to `true`. + +```toml +[tool.taskipy.settings] +use_vars = true + +[tool.taskipy.variables] +src_dir = "src" +package_dir = { var = "{src_dir}/package", recursive = true } + +[tool.taskipy.tasks] +echo = "echo {package_dir}" +``` + +In this example, we could run `task echo` and we would then see `src/package`. + ### Using Taskipy Without Poetry Taskipy was created with poetry projects in mind, but actually only requires a valid `pyproject.toml` file in your project's directory. As a result, you can use it even eithout poetry: -- cgit v1.2.3