summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/create_table7
-rw-r--r--src/lib/get_type13
-rw-r--r--src/lib/insert8
3 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/create_table b/src/lib/create_table
new file mode 100644
index 0000000..a783c50
--- /dev/null
+++ b/src/lib/create_table
@@ -0,0 +1,7 @@
+create_table() {
+ DB_PATH="$1"
+
+ sqlite3 "$DB_PATH" "CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"
+ sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX IF NOT EXISTS anchor ON searchIndex (name, type, path);"
+}
+
diff --git a/src/lib/get_type b/src/lib/get_type
new file mode 100644
index 0000000..9f04b53
--- /dev/null
+++ b/src/lib/get_type
@@ -0,0 +1,13 @@
+get_type() {
+ FILE="$1"
+ CATEGORY="$(echo "$FILE" | grep -Eo "\.[0-9].?\.html$")"
+
+ if [ -n "$CATEGORY" ]; then
+ case "$CATEGORY" in
+ .1*) echo "Command" ;;
+ .2*) echo "Service" ;;
+ .3*) echo "Function" ;;
+ *) echo "Object" ;;
+ esac
+ fi
+}
diff --git a/src/lib/insert b/src/lib/insert
new file mode 100644
index 0000000..31c1b4c
--- /dev/null
+++ b/src/lib/insert
@@ -0,0 +1,8 @@
+insert() {
+ DB_PATH="$1"
+ NAME="$2"
+ TYPE="$3"
+ PAGE_PATH="$4"
+
+ sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"$PAGE_PATH\");"
+}