add_file_tree¶
Operation to add a file tree (a.k.a. directory) to a project.
Example¶
The following example uses the prompt operation to prompt the user for a name,
and then uses it to generate a greeting message in one of the rendered files
(example-file.txt):
examples/operations/add_file_tree.yml¶steps:
"Prompt for name":
name: prompt
inputs:
- name: "name"
"Add files from `templates/add-file-tree`":
name: add_file_tree
target_dir: "./add-file-tree"
template_dir: "templates/add-file-tree"
template_variables:
dynamic_directory_name: "my-dynamic-directory"
dynamic_file_name: "my-dynamic-file"
This example references an add-file-tree directory, which looks like:
qwikstart/examples/operations
├── add_file_tree.yml
└── templates
└── add-file-tree
├── subdirectory
│ └── example-file.txt
└── {{ qwikstart.dynamic_directory_name }}
└── {{ qwikstart.dynamic_file_name }}.txt
The prompt operation, by default, adds variables to the template_variables
namespace. The operation definition above defines additional template variables,
dynamic_directory_name and dynamic_file_name, which are combined with those in the
template_variables from the global context. Running the operation defined above
produces the following:
./add-file-tree
├── subdirectory
│ └── example-file.txt
└── my-dynamic-directory
└── my-dynamic-file.txt
Required context¶
template_dirPath to directory containing template files. This path is relative to the qwikstart repo directory, which is typically the directory containing the
qwikstart.ymlfile.
Optional context¶
target_dirdefault: Working directory
Directory where files from
template_dirwill be written. This is relative to the current working directory.template_variablesDictionary of variables available when rendering the file template.
template_variable_prefixdefault:
'qwikstart'Template variables will be nested in this namespace when rendering; e.g:
{{<template_variable_prefix>.your_template_variable}}ignoreList of file patterns to ignore from source directory. Unix-shell-style wildcards are accepted. See https://docs.python.org/3/library/fnmatch.html