aboutsummaryrefslogtreecommitdiff
path: root/wiki
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-01-09 20:26:53 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-01-09 20:26:53 +0100
commit13c586e1afb51ad14a8d6175cf56ca573397f860 (patch)
tree8bee5f830e3221eb99871581c8c5a93b6c0d6d53 /wiki
parentWed, 09 Jan 2019 18:38:31 +0100 (diff)
downloadwiki-public-13c586e1afb51ad14a8d6175cf56ca573397f860.tar.gz
wiki-public-13c586e1afb51ad14a8d6175cf56ca573397f860.tar.xz
Update wiki script to support multiple wikis.
Diffstat (limited to 'wiki')
-rwxr-xr-xwiki124
1 files changed, 92 insertions, 32 deletions
diff --git a/wiki b/wiki
index 74097e1..3f6f68c 100755
--- a/wiki
+++ b/wiki
@@ -1,44 +1,104 @@
#!/bin/bash
-WIKIPATH=/home/hugo/wiki/public/
+WIKIROOT=/home/hugo/wiki/
+WIKI_LIST=$(ls $WIKIROOT | grep -v html)
# A simple script for managing a vimwiki git repo.
# Allows slightly simpler edits and commits.
-if [ $# -eq 0 ] || [ $1 = "edit" ]; then
- vim +VimwikiIndex
- exit
-fi
+wiki_list=""
-pushd $WIKIPATH
+function wiki_do {
+ wiki=$1
+ command=$2
-command=$1
+ pushd $WIKIROOT/$wiki
-case $command in
- commit)
- shift
- if [ $# -eq 0 ]; then
- msg="$(date --rfc-email)"
- else
- msg="$@"
- fi
- git add -A
- git commit -m "$msg"
- ;;
- ammend)
- shift
- if [ $# -eq 0 ]; then
- git commit --amend
- else
- msg="$@"
- git commit --amend -m "$msg"
- fi
- ;;
- g|go)
- wiki commit
- wiki push
+ shift
+ case $command in
+ commit)
+ shift
+ if [ $# -eq 1 ]; then
+ msg="$(date --rfc-email)"
+ else
+ msg="$@"
+ fi
+ git add -A
+ git commit -m "$msg"
+ ;;
+ ammend)
+ shift
+ if [ $# -eq 1 ]; then
+ git commit --amend
+ else
+ msg="$@"
+ git commit --amend -m "$msg"
+ fi
+ ;;
+ g|go)
+ wiki commit
+ wiki push
+ ;;
+ echo)
+ echo "-- $wiki --"
+ ;;
+ *)
+ eval "git $@"
+ ;;
+ esac
+}
+
+# == MAIN ==
+
+while [ $# -ne 0 ]; do
+ case $1 in
+ -w|--wiki)
+ shift
+ wiki_list="$1 $wiki_list"
+ shift
+ ;;
+ -l|--list)
+ shift
+ echo "Available Wikis:"
+ echo "================"
+ for w in $WIKI_LIST; do
+ echo " - $w"
+ done
+ exit
+ ;;
+ -h|--help|-?)
+ shift
+ cat - <<- EOF
+ Wiki helper. Usage:
+ --help | -h :: Display this help
+ --list | -l :: Show available wikis
+ --wiki | -w <wiki> :: specify a specific wiki for operation
+
+ Default acts on all wikis.
+
+ wi commit [msg] :: Create a git commit on specified wikis
+ wi ammend [msg] :: Change last commit
+ wi g [msg] :: wi commit [msg]; wi push
+ wi [git-command] :: run git commands on wikis
+ EOF
+ exit
;;
*)
- eval "git $@"
+ break
;;
-esac
+ esac
+done
+
+
+if [ $# -eq 0 ]; then
+ set -- ${wiki_list:-$WIKI_LIST}
+ vim $WIKIROOT/$1/index.*
+ exit
+fi
+
+for wiki in ${wiki_list:-$WIKI_LIST}; do
+ echo "== $wiki =="
+ wiki_do $wiki $@ &
+done
+
+wait