#!/usr/bin/env bash

create-symlink-files() {
    local source_pattern="$1"
    local target_dir="$2"

    # Create target directory
    ensure-directory "$target_dir"

    # Link each file in the source pattern
    for source_file in $source_pattern; do
        if [[ -f "$source_file" ]]; then
            local filename=$(basename "$source_file")
            local target_file="$target_dir/$filename"

            # Remove existing file if it exists
            if [[ -e "$target_file" || -L "$target_file" ]]; then
                rm -f "$target_file"
            fi

            # Create the symlink
            echo "Link $source_file to $target_file."
            ln -sf "$source_file" "$target_file"
        fi
    done
}
csf() {
    create-symlink-files "$@"
}
