add generate and read code from claude
This commit is contained in:
44
shared.sh
44
shared.sh
@@ -11,3 +11,47 @@ NC='\033[0m' # No Color
|
||||
|
||||
# SSH options - auto-accept new host keys
|
||||
SSH_OPTS="-o StrictHostKeyChecking=accept-new"
|
||||
|
||||
# Pause and wait for user to resolve an issue
|
||||
pause_for_user() {
|
||||
echo -e "${YELLOW}$1${NC}"
|
||||
read -p "Press Enter to continue after resolving..."
|
||||
}
|
||||
|
||||
# Extract value from .env file
|
||||
# Usage: get_env_value <file> <key>
|
||||
get_env_value() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
grep "^${key}=" "$file" 2>/dev/null | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'"
|
||||
}
|
||||
|
||||
# Add or update value in .env file
|
||||
# Usage: set_env_value <file> <key> <value>
|
||||
set_env_value() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
local value="$3"
|
||||
if grep -q "^${key}=" "$file" 2>/dev/null; then
|
||||
sed -i "s|^${key}=.*|${key}=\"${value}\"|" "$file"
|
||||
else
|
||||
echo "${key}=\"${value}\"" >> "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Add entry to .gitignore if not already present
|
||||
# Usage: add_to_gitignore <entry>
|
||||
add_to_gitignore() {
|
||||
local entry="$1"
|
||||
if [ -f .gitignore ]; then
|
||||
if ! grep -q "^${entry}$" .gitignore 2>/dev/null; then
|
||||
echo "$entry" >> .gitignore
|
||||
echo -e "${BLUE}Added $entry to .gitignore${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}$entry already in .gitignore${NC}"
|
||||
fi
|
||||
else
|
||||
echo "$entry" > .gitignore
|
||||
echo -e "${BLUE}Created .gitignore with $entry${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user