#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright Christopher Bratusek			#
#							#
#########################################################

export NO_AT_BRIDGE=1

export BSNG_PREFIX="/usr"
export BSNG_VERSION="10.7.4"
export BSNG_CODENAME="Stargazer"
export BSNG_DATADIR="/usr/share"

export PYTHON="/usr/bin/python3"
export PYTHONPATH="${PYTHONPATH}:${BSNG_DATADIR}/bashstyle-ng/ui"

case ${1} in
	--python | -P )
		shift
		echo ${PYTHON}
		[[ "${@}" ]] && ${PYTHON} "${@}"
	;;

	--doc | -d )
		xdg-open "${BSNG_DATADIR}/doc/bashstyle-ng/index.html"
	;;

	--update | -u | --backup | -b | --restore | -r | --reset | -R | -E | --enable | -D | --disable )
		/usr/bin/python3 "${BSNG_DATADIR}/bashstyle-ng/ui/config-update-helper.py" "${@}"
	;;

	--ini-get | -i )
		sed -n "s/^${2} = \(.*$\)/\1/p" "${HOME}"/.bashstyle-ng.ini | sed -e 's/\"//g'
	;;

	--ini-set | -I )
		shift
		SETTING=${1}
		shift
		VALUE="${*}"

		sed -e "s/^${SETTING} = .*$/${SETTING} = ${VALUE}/" -i "${HOME}"/.bashstyle-ng.ini
	;;

	--log | -l )
		less "${BSNG_LOGFILE}"
	;;

	* )
		/usr/bin/python3 "${BSNG_DATADIR}/bashstyle-ng/ui/bashstyle-ng.py" "${@}"
	;;
esac
