-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-findings.sh
More file actions
executable file
Β·129 lines (115 loc) Β· 4.06 KB
/
Copy pathinit-findings.sh
File metadata and controls
executable file
Β·129 lines (115 loc) Β· 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
# init-findings.sh β Scaffold the findings/ directory for research outputs.
#
# Creates the recommended directory structure under findings/ and optionally
# sets up a symlink to a cloud storage location (Dropbox, iCloud, Google Drive).
#
# Name: init-findings.sh
# Description: Scaffold findings/ directory for publication-library research
# Author: Alister Lewis-Bowen <alister@lewis-bowen.org>
# Usage: ./init-findings.sh [--cloud dropbox|icloud|gdrive|local]
# Dependencies: bash 4+
# Exit codes: 0 success, 1 error
set -euo pipefail
# ---------------------------------------------------------------------------
# Defaults
# ---------------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FINDINGS_DIR="${SCRIPT_DIR}/findings"
CLOUD_TYPE="${1:-}"
# Require pfb for terminal output
if ! command -v pfb &>/dev/null; then
echo "ERROR: pfb is required but not found. Install it from https://github.com/ali5ter/pfb" >&2
exit 1
fi
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
# @description Print a usage message and exit
usage() {
echo "Usage: $0 [--cloud dropbox|icloud|gdrive|local]"
echo
echo " --cloud Set up a symlink to cloud storage (optional)"
echo
echo "Examples:"
echo " $0 # Create findings/ locally"
echo " $0 --cloud dropbox # Symlink findings/ to Dropbox"
exit 1
}
# @description Resolve the cloud storage path for a given provider
# @param $1 Cloud provider: dropbox, icloud, gdrive, or local
# @return Prints the resolved path, or exits 1 if unknown
cloud_path() {
local provider="${1}"
local lib_name
lib_name="$(basename "${SCRIPT_DIR}")"
case "${provider}" in
dropbox)
echo "${HOME}/Dropbox/${lib_name}/findings"
;;
icloud)
echo "${HOME}/Library/Mobile Documents/com~apple~CloudDocs/${lib_name}/findings"
;;
gdrive)
echo "${HOME}/Google Drive/My Drive/${lib_name}/findings"
;;
local)
echo "${FINDINGS_DIR}"
;;
*)
echo "ERROR: Unknown cloud provider '${provider}'. Use: dropbox, icloud, gdrive, local" >&2
exit 1
;;
esac
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
# Parse arguments
CLOUD=""
while [[ $# -gt 0 ]]; do
case "$1" in
--cloud)
CLOUD="${2:-}"
shift 2
;;
--help|-h)
usage
;;
*)
echo "ERROR: Unknown argument '$1'" >&2
usage
;;
esac
done
pfb heading "publication-library β findings/ setup" "π"
echo
# Determine where findings will live
if [[ -n "${CLOUD}" ]]; then
CLOUD_DEST="$(cloud_path "${CLOUD}")"
pfb info "Cloud storage: ${CLOUD} β ${CLOUD_DEST}"
# Create the cloud directory and scaffold inside it
mkdir -p "${CLOUD_DEST}/topics"
mkdir -p "${CLOUD_DEST}/projects"
mkdir -p "${CLOUD_DEST}/sessions"
# Create symlink if findings/ doesn't already exist
if [[ -e "${FINDINGS_DIR}" ]]; then
pfb info "${FINDINGS_DIR} already exists β skipping symlink"
else
ln -s "${CLOUD_DEST}" "${FINDINGS_DIR}"
pfb success "Symlink created: ${FINDINGS_DIR} β ${CLOUD_DEST}"
fi
else
# Local only
mkdir -p "${FINDINGS_DIR}/topics"
mkdir -p "${FINDINGS_DIR}/projects"
mkdir -p "${FINDINGS_DIR}/sessions"
pfb success "Created: ${FINDINGS_DIR}/"
fi
echo
pfb subheading "findings/"
pfb subheading " βββ topics/ β topic reference notes (e.g. synthesisers.md)"
pfb subheading " βββ projects/ β project research notes"
pfb subheading " βββ sessions/ β dated session logs (YYYY-MM-DD-topic.md)"
echo
pfb success "Done. findings/ is gitignored and will not be committed."