Copier Features Guide
This template requires Copier 9.17.0 or higher. Here are key features you can use.
--ask Flag
Force re-prompting for specific questions during update, even if already answered. This requires the --skip-answered flag as well, in order to skip all other questions.
# Normal update skips answered questions
copier update -a .copier-answers/devops.yaml
# Force re-prompting for specific questions
copier update --ask artifact_id --ask version -a .copier-answers/devops.yaml --skip-answered
# Combine with other flags
copier update --ask dtr_org -a .copier-answers/devops.yaml --skip-answered
Use case: Change just one or two answers without going through all prompts.
check-update Command
Check if a template update is available without actually updating.
# Check if update available
copier check-update -a .copier-answers/devops.yaml
Git Template Caching
Remote templates are cached as local Git mirrors for faster subsequent operations.
# First run - clones template (slower)
copier copy https://coderepo.mobilehealth.va.gov/scm/ckm/ngss-devops-template.git ./my-project
# Subsequent runs - uses cached mirror (much faster)
copier update -a ./my-project/.copier-answers/devops.yaml ./my-project
# Cache location
ls ~/.cache/copier/ # Linux
ls ~/Library/Caches/copier/ # macOS
User Settings
Configure default answers and trusted repositories.
# Define default answers applied to all templates
defaults:
author_name: James Hockley
author_email: james@example.com
dtr_org: ckm
# Trust specific template sources (no --trust needed)
trust:
- https://coderepo.mobilehealth.va.gov/*
- /Users/dallas/IdeaProjects/*
The trust feature may not work for all CLI invocations. Use --trust flag as a fallback.
|
StrictUndefined Mode
This template uses strict mode to catch undefined variables.
# In copier.yaml
_envops:
undefined: strict
If a template references an undefined variable, you’ll get a clear error message instead of a silent empty string.
Better Error Messages
Invalid choice errors now show the variable name and valid options:
Error: Invalid choice for 'database': 'mongodb'
Valid choices are: postgresql, mysql, sqlite
Executable Bit Propagation
Executable permissions are correctly preserved during updates, even with git core.fileMode=false.
Data Files
Pass additional data without re-prompting:
# Create a data file
cat > dependencies.yaml << EOF
service_dependencies:
- ckm/service-a:v2.0.0
- ckm/service-b:v1.5.0
EOF
# Update with the data file
copier update -a .copier-answers/devops.yaml --data-file dependencies.yaml
Useful Copier Commands
# Copy template to new project
copier copy <template> <destination>
# Update existing project
copier update -a .copier-answers/devops.yaml
# Update with specific version
copier update --vcs-ref v1.2.0 -a .copier-answers/devops.yaml
# Force all defaults (non-interactive)
copier update --defaults -a .copier-answers/devops.yaml
# See what would change (dry run)
copier update --pretend -a .copier-answers/devops.yaml
# Skip specific questions
copier update --skip-answered --ask version -a .copier-answers/devops.yaml