A tool for managing my collection of notes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
945 B

#!/usr/bin/env bash
initKnowledgeBase(){
local output
necho -e "${YELLOW}Initialising Knowledge base${NC}"
vecho "Directory: $dataDir"
if [ "$verbose" -gt 0 ]; then
output="/dev/stdout"
else
output="/dev/null"
fi
[ -e "$dataDir" ] && die "$dataDir already exists"
mkdir -p "$dataDir"
if [ "$dogit" -gt 0 ]; then
git init "$dataDir" > "$output"
# TODO: make gitignore use new sqlite file
echo "/knowledgebase.sqlite3" >> "${dataDir}/.gitignore"
git -C "$dataDir" add .gitignore > "$output"
git -C "$dataDir" commit -m "Knowledge base initialised" > output
fi
initDB
}
initDB(){
vecho "Creating Database"
echo 'CREATE TABLE items
(id integer primary key, filename text, title text, type text);
CREATE TABLE tags
(id integer primary key, name text);
CREATE TABLE links
(id integer primary key, itemID integer, tagID integer); ' |
sqlite3 "${sqliteFile}"
necho -e "${GREEN}Initialised Knowledge base${NC}"
}