From ce8388d6d81ccba5c5716bd68fe26ecf1b74782f Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sun, 12 Jun 2016 22:48:08 -0700 Subject: [PATCH] Console bin wrapper, make file, readme updates --- README.md | 14 +++++++------- bin/screepsconsole.sh | 20 ++++++++++++++++++++ makefile | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100755 bin/screepsconsole.sh create mode 100644 makefile diff --git a/README.md b/README.md index cb24c92..777ea8e 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,15 @@ any html tags and adds colors. ## Installation -1. Download this package, either from the Releases page or from a git clone. +1. Make sure `virtualenv` is installed- `pip install virtualenv` -2. Install dependencies using `pip`. While not required, it's recommended that - you use [virtualenv](http://www.bogotobogo.com/python/python_virtualenv_virtualenvwrapper.php) - rather than installing your repositories globally. +2. Run `make` -``` -pip install -r requirements.txt -``` +3. Run `make install` + +4. Create settings (as per the instructions below). + +5. Run `screepsconsole` from inside the terminal. ## Settings diff --git a/bin/screepsconsole.sh b/bin/screepsconsole.sh new file mode 100755 index 0000000..1dff7c0 --- /dev/null +++ b/bin/screepsconsole.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Get real directory in case of symlink +if [[ -L "${BASH_SOURCE[0]}" ]] +then + DIR="$( cd "$( dirname $( readlink "${BASH_SOURCE[0]}" ) )" && pwd )" +else + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +fi +cd $DIR + +ENV="$DIR/../env/bin/activate" +if [ ! -f $ENV ]; then + echo 'Virtual Environment Not Installed' + exit -1 +fi + +SCRIPT="$DIR/../screeps_console/interactive.py" +source $ENV +$SCRIPT "$@" diff --git a/makefile b/makefile new file mode 100644 index 0000000..f225147 --- /dev/null +++ b/makefile @@ -0,0 +1,35 @@ + +SHELL:=/bin/bash +ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +.PHONY: all fresh dependencies install fulluninstall uninstall removedeps + +all: dependencies + +fresh: fulluninstall dependencies + +fulluninstall: uninstall cleancode + +install: + # Create link in /usr/local/bin to screeps stats program. + ln -s -f $(ROOT_DIR)/bin/screepsconsole.sh /usr/local/bin/screepsconsole + +dependencies: + if [ ! -d $(ROOT_DIR)/env ]; then virtualenv $(ROOT_DIR)/env; fi + source $(ROOT_DIR)/env/bin/activate; yes w | pip install -r $(ROOT_DIR)/requirements.txt + +uninstall: + # Remove screepsstats link in /user/local/bin + if [ -L /usr/local/bin/screepsconsole.sh ]; then \ + rm /usr/local/bin/screepsconsole; \ + fi; + +cleancode: + # Remove existing environment + if [ -d $(ROOT_DIR)/env ]; then \ + rm -rf $(ROOT_DIR)/env; \ + fi; + # Remove compiled python files + if [ -d $(ROOT_DIR)/screep_etl ]; then \ + rm -f $(ROOT_DIR)/screep_etl/*.pyc; \ + fi;