<commit_before>#!/bin/sh

PROJECT_NAME="foobar"

function usage {
    echo "usage: $0 <script> <dir>"
    exit 1
}

function notice {
    echo "notice: $@"
}

function warning {
    echo "warning: $@"
}

function error {
    echo "error: $@"
    exit 1
}

function backup {
    SUFFIX=$( date +"%Y-%m-%d__%Hh%Mm%Ss" )
    echo $1.$SUFFIX
}

if [ $# -lt 1 ]; then
    usage
fi

# The directory used for generate the template
SCRIPT=$1
DIR=$2
DEST_DIR=$DIR.distillery

if [ ! -d $DIR ]; then
    error "'$DIR': no such file or directory. Make sur to give a valid directory"
fi

if [ -d $DEST_DIR ]; then
    warning "'$DEST_DIR' exists."
    BAK=$( backup $DEST_DIR )
    notice "create a backup of '$DEST_DIR' into '$BAK'"
    mv $DEST_DIR $BAK
fi

notice "create '$DEST_DIR'"
mkdir -p $DEST_DIR

for file in $( find $DIR | cut -d '/' -f 2- ); do
    FILE="$DIR/$file"
    if [ ! -d $FILE ] && [ -f $FILE ] ; then
        DFILE="$( echo $file | sed "s|$PROJECT_NAME|PROJECT_NAME|g" )"
        DFILE="$( echo $DFILE | sed 's|/|!|g' )"
        DFILE="$DEST_DIR/$DFILE"
        echo "$SCRIPT $FILE > $DFILE"
        $SCRIPT $FILE > $DFILE
    fi
done<commit_msg>update 2distillery script<commit_after>#!/bin/sh

PROJECT_NAME="foobar"

function usage {
    echo "usage: $0 <script> <dir>"
    exit 1
}

function notice {
    echo "notice: $@"
}

function warning {
    echo "warning: $@"
}

function error {
    echo "error: $@"
    exit 1
}

function backup {
    SUFFIX=$( date +"%Y-%m-%d__%Hh%Mm%Ss" )
    echo $1.$SUFFIX
}

if [ $# -lt 2 ]; then
    usage
fi

# The directory used for generate the template
SCRIPT=$1
DIR=$2
DEST_DIR=$DIR.distillery

if [ ! -d $DIR ]; then
    error "'$DIR': no such file or directory. Make sur to give a valid directory"
fi

if [ -d $DEST_DIR ]; then
    warning "'$DEST_DIR' exists."
    BAK=$( backup $DEST_DIR )
    notice "create a backup of '$DEST_DIR' into '$BAK'"
    mv $DEST_DIR $BAK
fi

notice "create '$DEST_DIR'"
mkdir -p $DEST_DIR

function filter {
    find $DIR\
         -not -path "*/local*"\
    -and -not -path "*/_server*"\
    -and -not -path "*/_client*"\
    -and -not -path "*/_deps*"\
    -and -not -path "*/trash*"\
    -and -not -name ".*"
}

for file in $( filter | cut -d '/' -f 2- ); do
    FILE="$DIR/$file"
    if [ ! -d $FILE ] && [ -f $FILE ] ; then
        DFILE="$( echo $file | sed "s|$PROJECT_NAME|PROJECT_NAME|g" )"
        DFILE="$( echo $DFILE | sed 's|/|!|g' )"
        DFILE="$DEST_DIR/$DFILE"
        echo "$SCRIPT $FILE > $DFILE"
        $SCRIPT $FILE > $DFILE
    fi
done
{'fraction_non_alphanumeric': 0.17490196078431372, 'fraction_numerical': 0.006666666666666667, 'mean_word_length': 2.5430555555555556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1269705', 'n_tokens_mistral': 1022, 'n_tokens_neox': 982, 'n_words': 290}