<commit_before>#!/bin/bash
set -euo pipefail
dir="$(dirname $(readlink -f "$0"))"
own="$(pwd)"

function usage() {
	>&2 echo "Usage: ablog [COMMAND]"
	>&2 echo
	>&2 echo "Commands:"
	>&2 echo "  init"
	>&2 echo "  build [default]"
	>&2 echo "  server"
	>&2 echo "  patch"
	>&2 echo "  update"
	exit 1
}

function main() {
	if [ $# -gt 1 ]; then
		>&2 echo "ablog takes exactly 0 or 1 arguments"
		>&2 echo
		usage
	elif [ $# -eq 0 ]; then
		cmd=build
	else
		cmd="$1"; shift
	fi

	case $cmd in
		"init")
			if [ ! -e "$own/config.json" ]; then
				cp "$dir/config.json" "$own"
				cp "$dir/.travis.yml" "$own"
				cp -a "$dir/_posts"   "$own"
				cp -a "$dir/run"      "$own"
				mkdir -p "$own/_assets/sass"
				cp -a "$dir/_assets/static" "$own/_assets"
				( cd "$own" ; "$0" patch )
			fi
			;;
		"patch")
			"$dir/run/patch.sh"
			;;
		"update")
			npm update "$(grep '_from' "$dir/package.json" | \
				sed -r 's/^.*: "([^@"]+).*$/\1/')"
			;;
		"build")
			if [ ! -e "$own/config.json" ]; then
				>&2 echo "ablog needs a config.json file to run"
				>&2 echo
				usage
			fi
			( cd $dir ; npm run build -- -c="$own/dist" )
			;;
		"server")
			if [ ! -e "$own/config.json" ]; then
				>&2 echo "ablog needs a config.json file to run"
				>&2 echo<commit_msg>Make patch work with global install<commit_after>#!/bin/bash
set -euo pipefail
dir="$(dirname $(readlink -f "$0"))"
own="$(pwd)"

function usage() {
	>&2 echo "Usage: ablog [COMMAND]"
	>&2 echo
	>&2 echo "Commands:"
	>&2 echo "  init"
	>&2 echo "  build [default]"
	>&2 echo "  server"
	>&2 echo "  patch"
	>&2 echo "  update"
	exit 1
}

function main() {
	if [ $# -gt 1 ]; then
		>&2 echo "ablog takes exactly 0 or 1 arguments"
		>&2 echo
		usage
	elif [ $# -eq 0 ]; then
		cmd=build
	else
		cmd="$1"; shift
	fi

	case $cmd in
		"init")
			if [ ! -e "$own/config.json" ]; then
				cp "$dir/config.json" "$own"
				cp "$dir/.travis.yml" "$own"
				cp -a "$dir/_posts"   "$own"
				cp -a "$dir/run"      "$own"
				mkdir -p "$own/_assets/sass"
				cp -a "$dir/_assets/static" "$own/_assets"
				"$0" patch
			fi
			;;
		"patch")
			( cd "$dir" ; "$dir/run/patch.sh" )
			;;
		"update")
			npm update "$(grep '_from' "$dir/package.json" | \
				sed -r 's/^.*: "([^@"]+).*$/\1/')"
			;;
		"build")
			if [ ! -e "$own/config.json" ]; then
				>&2 echo "ablog needs a config.json file to run"
				>&2 echo
				usage
			fi
			( cd $dir ; npm run build -- -c="$own/dist" )
			;;
		"server")
			if [ ! -e "$own/config.json" ]; then
				>&2 echo "ablog needs a config.json file to run"
				>&2 echo
{'fraction_non_alphanumeric': 0.21517996870109546, 'fraction_numerical': 0.017996870109546165, 'mean_word_length': 2.3912466843501328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '4160948', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1033, 'n_words': 308}