diff options
author | Teddy Wing | 2018-04-18 23:55:20 +0200 |
---|---|---|
committer | Teddy Wing | 2018-04-18 23:55:20 +0200 |
commit | 5382bef7e53a06a4b2b7148b099f73382a5bbd09 (patch) | |
tree | dcf0eb8f305a244fcf0c262533bda6fd8c16db02 | |
parent | 83ed5e7c00e2a02e7100e15965b50461eb80f0ce (diff) | |
download | redprine-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-x | redprine | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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 |