33 lines
854 B
Bash
33 lines
854 B
Bash
|
#!/usr/bin/env bash
|
||
|
# README # ------
|
||
|
# Configure the config.json file in this same directory for an AI chatbot to
|
||
|
# Assist in making direct changes to files.
|
||
|
set -euo pipefail
|
||
|
|
||
|
# Make sure jq is available
|
||
|
if ! command -v jq &> /dev/null; then
|
||
|
echo "Error: jq is required but not installed"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Make sure config.json exists
|
||
|
if [ ! -f "config.json" ]; then
|
||
|
echo "Error: config.json not found in current directory"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "Creating directories and files..."
|
||
|
|
||
|
# Process each key in the JSON configuration
|
||
|
for file in $(jq -r 'keys[]' config.json); do
|
||
|
# Create directory if it doesn't exist
|
||
|
dir=$(dirname "$file")
|
||
|
mkdir -p "$dir"
|
||
|
|
||
|
# Write content to file
|
||
|
jq -r --arg file "$file" '.[$file]' config.json > "$file"
|
||
|
echo "Created: $file"
|
||
|
done
|
||
|
|
||
|
echo "Configuration files have been created successfully!"
|