format
This commit is contained in:
@@ -125,7 +125,7 @@ create_settings_file() {
|
|||||||
local api_key="$2"
|
local api_key="$2"
|
||||||
|
|
||||||
# Write to .env file
|
# Write to .env file
|
||||||
cat <<EOF > "$GEMINI_ENV_FILE"
|
cat <<EOF >"$GEMINI_ENV_FILE"
|
||||||
GOOGLE_GEMINI_BASE_URL="$base_url"
|
GOOGLE_GEMINI_BASE_URL="$base_url"
|
||||||
GEMINI_API_KEY="$api_key"
|
GEMINI_API_KEY="$api_key"
|
||||||
GEMINI_MODEL="gemini-3-pro-preview"
|
GEMINI_MODEL="gemini-3-pro-preview"
|
||||||
@@ -134,7 +134,7 @@ EOF
|
|||||||
|
|
||||||
# Write to settings.json
|
# Write to settings.json
|
||||||
local settings_json_path="$GEMINI_CONFIG_DIR/settings.json"
|
local settings_json_path="$GEMINI_CONFIG_DIR/settings.json"
|
||||||
cat <<EOF > "$settings_json_path"
|
cat <<EOF >"$settings_json_path"
|
||||||
{
|
{
|
||||||
"general": {
|
"general": {
|
||||||
"previewFeatures": true
|
"previewFeatures": true
|
||||||
@@ -179,20 +179,20 @@ main() {
|
|||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-k|--key)
|
-k | --key)
|
||||||
api_key="$2"
|
api_key="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-t|--test)
|
-t | --test)
|
||||||
test_only=true
|
test_only=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-s|--show)
|
-s | --show)
|
||||||
show_settings=true
|
show_settings=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h | --help)
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [OPTIONS]
|
Usage: $0 [OPTIONS]
|
||||||
|
|
||||||
This script automatically tests multiple API endpoints and selects the working one:
|
This script automatically tests multiple API endpoints and selects the working one:
|
||||||
@@ -216,13 +216,13 @@ Interactive mode (no arguments):
|
|||||||
Environment Variables:
|
Environment Variables:
|
||||||
API_KEY API key for authentication
|
API_KEY API key for authentication
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
print_error "Unknown option: $1"
|
print_error "Unknown option: $1"
|
||||||
print_info "Use --help for usage information"
|
print_info "Use --help for usage information"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ write_env_to_shell() {
|
|||||||
|
|
||||||
# 确保文件末尾有换行
|
# 确保文件末尾有换行
|
||||||
if [ -s "$rc_file" ] && [ "$(tail -c1 "$rc_file" | wc -l)" -eq 0 ]; then
|
if [ -s "$rc_file" ] && [ "$(tail -c1 "$rc_file" | wc -l)" -eq 0 ]; then
|
||||||
echo "" >> "$rc_file"
|
echo "" >>"$rc_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 转义特殊字符(使用单引号包裹更安全)
|
# 转义特殊字符(使用单引号包裹更安全)
|
||||||
@@ -73,12 +73,12 @@ write_env_to_shell() {
|
|||||||
local tmp_file
|
local tmp_file
|
||||||
tmp_file=$(mktemp)
|
tmp_file=$(mktemp)
|
||||||
if [ -s "$rc_file" ]; then
|
if [ -s "$rc_file" ]; then
|
||||||
grep -v "^export $var_name=" "$rc_file" | grep -v "^set -Ux $var_name " > "$tmp_file" 2>/dev/null || true
|
grep -v "^export $var_name=" "$rc_file" | grep -v "^set -Ux $var_name " >"$tmp_file" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
echo "$export_line" >> "$tmp_file"
|
echo "$export_line" >>"$tmp_file"
|
||||||
|
|
||||||
# 保留原文件权限
|
# 保留原文件权限
|
||||||
cat "$tmp_file" > "$rc_file"
|
cat "$tmp_file" >"$rc_file"
|
||||||
rm -f "$tmp_file"
|
rm -f "$tmp_file"
|
||||||
|
|
||||||
# 立即生效
|
# 立即生效
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ create_settings() {
|
|||||||
|
|
||||||
# Write config.json for VSCode Claude extension
|
# Write config.json for VSCode Claude extension
|
||||||
local config_json_path="$CLAUDE_CONFIG_DIR/config.json"
|
local config_json_path="$CLAUDE_CONFIG_DIR/config.json"
|
||||||
cat <<EOF > "$config_json_path"
|
cat <<EOF >"$config_json_path"
|
||||||
{
|
{
|
||||||
"primaryApiKey": "xcodecli"
|
"primaryApiKey": "xcodecli"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user