init - dossier - console collection manager
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 3bf0b90aa2f8f10172f97fcc092d990407e7bf22
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Sat, 14 Jul 2018 21:04:39 +0200
init
Diffstat:
A cdb | 49 +++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+), 0 deletions(-)
---
DIR diff --git a/cdb b/cdb
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+REPO=/home/solene/dev/cbd/games/
+
+
+show() {
+ cd "${REPO}"
+ for attribute in *
+ do
+ if [ -f "${attribute}/${1}" ]
+ then
+ printf "%15s: %s\n" ${attribute} "$(cat ${attribute}/${1})"
+ fi
+ done
+}
+
+show_attributes() {
+ cd "${REPO}"
+ (
+ for attribute in $(find . -type d -maxdepth 1 -mindepth 1)
+ do
+ printf "${attribute}" | cut -d '/' -f 2
+ done
+ ) | sort | tr '\n' ' '
+ exit 0
+}
+
+# $1 identifier
+# $2 attribute
+# $3 value
+add_value() {
+ cd "$REPO"
+ mkdir -p "$2"
+ printf '%s' "$3" > "$2"/"$1"
+ exit 0
+}
+
+# $1 attribute
+# $2 value
+search_value() {
+ cd "$REPO"
+ grep -r "$2" "$1"
+ exit 0
+}
+
+if [ "$1" = "search" ] && [ "$#" -eq 3 ]; then search_value "$2" "$3" ; fi
+if [ "$1" = "attrs" ]; then show_attributes ; fi
+if [ "$#" -eq 3 ]; then add_value "$1" "$2" "$3" ; fi
+show "$1"