aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-04-18 23:55:20 +0200
committerTeddy Wing2018-04-18 23:55:20 +0200
commit5382bef7e53a06a4b2b7148b099f73382a5bbd09 (patch)
treedcf0eb8f305a244fcf0c262533bda6fd8c16db02
parent83ed5e7c00e2a02e7100e15965b50461eb80f0ce (diff)
downloadredprine-5382bef7e53a06a4b2b7148b099f73382a5bbd09.tar.bz2
Store cache file in `XDG_DATA_HOME`; Rename cache file
Get rid of the temporary location and name of our cache file. Now use the XDG data directory and create ourselves a subdirectory under it where we can store our cache files. We want a separate cache file for each repository you run Redprine against. To differentiate the cache files, name them with the owner-repo combination passed in as a command line argument. Get rid of the slash in the owner-repo string because this is a filename. For example, 'eagle-jump/engine' turns into 'eagle-jump--engine'.
-rwxr-xr-xredprine9
1 files changed, 8 insertions, 1 deletions
diff --git a/redprine b/redprine
index 13e2a85..3191853 100755
--- a/redprine
+++ b/redprine
@@ -12,7 +12,9 @@ GITHUB_OWNER_REPO=''
REDMINE_BASE_URL=''
REDMINE_TOKEN=''
-CACHE_FILE="$HOME/redprine.json"
+XDG_DATA_HOME=${XDG_DATA_HOME:-"${HOME}/.local/share"}
+REDPRINE_DATA_DIR=${REDPRINE_DATA_DIR:-"${XDG_DATA_HOME}/redprine"}
+CACHE_FILE="${REDPRINE_DATA_DIR}/${GITHUB_OWNER_REPO/\//--}.json"
function print_usage () {
@@ -183,6 +185,10 @@ function exit_with_error () {
exit 1
}
+function preflight () {
+ mkdir -p "$REDPRINE_DATA_DIR"
+}
+
function argument_error () {
local flag="$1"
@@ -285,5 +291,6 @@ function parse_arguments () {
}
+preflight
parse_arguments "$@"
main