# Example Runfile with simple function definitions
# Simple function with argument substitution
docker_shell() docker compose exec $1 bash
# Nested command with colon notation
docker:shell() docker compose exec ${1:-app} bash
# Another nested command example
docker:logs() docker compose logs -f $1
# Function with multiple arguments
git:commit() git add . && git commit -m "$1" && echo "${2:-done}"
# Function using $@ for all arguments
echo_all() echo "All args: $@"
# Function that ignores arguments
echo_no_args() echo "No args function called" \
&& echo "This function does not use its arguments" \
&& echo "It just prints a fixed message"
# Deploy with multiple steps
docker:deploy() {
echo "Building image..."
docker build -t myapp:$1 .
echo "Pushing to registry..."
docker push myapp:$1
echo "Restarting containers..."
docker compose up -d
echo "✓ Deployed version $1"
}
# Deploy commands:
deploy:patch() {
./scripts/deploy.sh patch
}
deploy:minor() {
./scripts/deploy.sh minor
}
deploy:major() {
./scripts/deploy.sh major
}
# Windows specific command (will not be listed on non-Windows systems)
# @os windows
deploy:example() {
echo "Running Windows-specific deployment steps..."
./scripts/deploy_windows.bat
}
# Will run on unix systems only as windows version is defined above
deploy:example() {
echo "Running Unix-specific deployment steps..."
./scripts/deploy_unix.sh
}
# Will only run on unix systems
# @os unix
incompatible_with_pwsh() echo "" | grep
# Will run in pwsh even on unix systems
# @shell pwsh
pwsh_example() {
Write-Host "This runs in PowerShell!"
}
# Inline Python
# @shell python
python:hello() {
print("Hello from inline Python!")
for i in range(3):
print(f"Count: {i}")
}
# Inline Node.js
# @shell node
node:hello() {
console.log("Hello from inline Node.js!");
for (let i = 0; i < 3; i++) {
console.log(`Count: ${i}`);
}
}
# Inline semicolon block
function test_inline() { echo "a"; echo "b"; echo "c" }