<commit_before>#!/usr/bin/env bash


#1 option name
#2 default value
getOption() {

	if [ $# -ne 2 ]; then
		return
	fi


	len=`tmux show-environment "$1" 2>/dev/null | wc -l`
	if [ $len -eq 1 ];
		then echo "`tmux show-environment $1`";
		else echo "$2";
	fi
}


TTK_LOG_DELAY=`getOption TTK_LOG_DELAY 2`
TTK_WRITE_DELAY=`getOption TTK_WRITE_DELAY 10`;
TTK_PLUGIN_DIR=`getOption TTK_PLUGIN_DIR "$HOME/.timekeeper"`;
TTK_LOG_DIR=`getOption TTK_LOG_DIR "$HOME/TTK/"`;

#TODO check plugin dir exists
#TODO check wete dir exists or can be created and is writeable
#TODO how to tell it to user if this calls plugin manager?

source "$TTK_PLUGIN_DIR/scripts/parser.sh";
source "$TTK_PLUGIN_DIR/scripts/save.sh";
source "$TTK_PLUGIN_DIR/scripts/run.sh";
source "$TTK_PLUGIN_DIR/stats/stats.sh";<commit_msg>Settings validation<commit_after>#!/usr/bin/env bash


#1 option name
#2 default value
getOption() {

	if [ $# -ne 2 ]; then
		return
	fi


	len=`tmux show-environment "$1" 2>/dev/null | wc -l`
	if [ $len -eq 1 ];
		then echo "`tmux show-environment $1`";
		else echo "$2";
	fi
}


TTK_LOG_DELAY=`getOption TTK_LOG_DELAY 2`
TTK_WRITE_DELAY=`getOption TTK_WRITE_DELAY 10`;
TTK_PLUGIN_DIR=`getOption TTK_PLUGIN_DIR "$HOME/.timekeeper"`;
TTK_LOG_DIR=`getOption TTK_LOG_DIR "$HOME/TTK/"`;


if [ "$TTK_WRITE_DELAY" -lt "$TTK_LOG_DELAY" ]; then
	echo "Write delay cannot be shorter than Log delay";
	return 1;
fi

if [ ! -f "$TTK_PLUGIN_DIR/timekeeper.tmux" ]; then
	echo "Incorrect plugin dir!";
	return 1;
fi

if [ ! -w "$TTK_LOG_DIR" ]; then
	echo "Log dir is not writeable";
	return 1;
fi
#TODO how to tell it to user if this calls plugin manager?

source "$TTK_PLUGIN_DIR/scripts/parser.sh";
source "$TTK_PLUGIN_DIR/scripts/save.sh";
source "$TTK_PLUGIN_DIR/scripts/run.sh";
source "$TTK_PLUGIN_DIR/stats/stats.sh";
{'fraction_non_alphanumeric': 0.1371900826446281, 'fraction_numerical': 0.013774104683195593, 'mean_word_length': 4.675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2434050', 'n_tokens_mistral': 787, 'n_tokens_neox': 730, 'n_words': 191}