-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinit.sh
More file actions
81 lines (72 loc) · 2.08 KB
/
Copy pathinit.sh
File metadata and controls
81 lines (72 loc) · 2.08 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
#!/bin/bash
# title: "init"
# author: Hsieh-Ting Lin
# date: "2025-05-19"
# version: 1.0.0
# description:
# --END-- #
set -ue
set -o pipefail
trap "echo 'END'" EXIT
# Check if clasp is installed
if ! command -v clasp &>/dev/null; then
echo "Error: 'clasp' is not installed or not in your PATH."
echo "You can install it with: npm install -g @google/clasp"
exit 1
fi
# Check if project is already initialized
if [ -f ".clasp.json" ]; then
echo "An existing clasp project was detected."
read -p "Do you want to start over and create a new Slides project? (y/n): " USER_CHOICE
if [[ "$USER_CHOICE" =~ ^[Yy]$ ]]; then
echo "Starting over..."
rm -f .clasp.json
rm -f appsscript.json
else
echo "Opening existing Slides project..."
clasp open-container
exit 0
fi
fi
# Prompt user for the title of the Google Slides presentation
read -p "Enter the title for your new Google Slides presentation: " SLIDES_TITLE
# Check if the input is empty
if [ -z "$SLIDES_TITLE" ]; then
echo "Error: Title cannot be empty."
exit 1
fi
# Create a new Google Slides project
clasp create --type slides --title "$SLIDES_TITLE"
if [ $? -ne 0 ]; then
echo "Failed to create the Slides project."
exit 1
fi
# Copy the example appscript configuration file
if [ -f "appsscript.json" ]; then
read -p "appsscript.json already exists. Do you want to overwrite it? (y/n): " OVERWRITE_CHOICE
if [[ "$OVERWRITE_CHOICE" =~ ^[Yy]$ ]]; then
echo "Copying appscript.example.json to appscript.json..."
cp appsscript.example.json appsscript.json
if [ $? -ne 0 ]; then
echo "Failed to copy the appscript configuration file."
exit 1
fi
else
echo "Keeping existing appsscript.json file."
fi
else
echo "Copying appscript.example.json to appscript.json..."
cp appsscript.example.json appsscript.json
if [ $? -ne 0 ]; then
echo "Failed to copy the appscript configuration file."
exit 1
fi
fi
# Push the code to the new project
clasp push
if [ $? -ne 0 ]; then
echo "Failed to push the code."
exit 1
fi
# Open the Google Slides presentation
clasp open-container