-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path19-configuration.sh
More file actions
executable file
·131 lines (110 loc) · 3.76 KB
/
Copy path19-configuration.sh
File metadata and controls
executable file
·131 lines (110 loc) · 3.76 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
130
131
#!/bin/bash
# Example 19: Configuration
# Demonstrates configuration management
set -e # Exit on error
echo "=== DeepL CLI Example 19: Configuration ==="
echo
# Check if API key is configured
if ! deepl auth show &>/dev/null; then
echo "❌ Error: API key not configured"
echo "Run: deepl auth set-key YOUR_API_KEY"
exit 1
fi
echo "✓ API key configured"
echo
# Example 1: View all configuration
echo "1. View all configuration"
deepl config list
echo
echo "1b. View configuration in text format:"
deepl config list --format text
echo
# Example 2: Get specific values
echo "2. Get specific configuration values"
echo " Cache enabled:"
deepl config get cache.enabled
echo
echo " Default target languages:"
deepl config get defaults.targetLangs
echo
echo " API base URL:"
deepl config get api.baseUrl
echo
# Example 3: Set configuration values
echo "3. Set configuration values"
echo " Setting default target languages to ES, FR, DE..."
deepl config set defaults.targetLangs es,fr,de
echo
echo " Setting output color to false..."
deepl config set output.color false
echo
echo " Setting cache max size to 2GB..."
deepl config set cache.maxSize 2147483648
echo
# Example 4: Verify changes
echo "4. Verify configuration changes"
echo " Target languages:"
deepl config get defaults.targetLangs
echo
echo " Output color:"
deepl config get output.color
echo
echo " Cache max size:"
deepl config get cache.maxSize
echo
# Example 5: Configure cache settings
echo "5. Configure cache settings"
echo " Disable caching..."
deepl config set cache.enabled false
echo " Cache status:"
deepl config get cache.enabled
echo
echo " Re-enable caching..."
deepl config set cache.enabled true
echo " Cache status:"
deepl config get cache.enabled
echo
# Example 6: Configure API endpoint (demonstration only)
echo "6. Configure API endpoint"
echo " The CLI auto-detects the correct endpoint from your API key:"
echo " - Keys ending with :fx → api-free.deepl.com"
echo " - All other keys → api.deepl.com"
echo
echo " For regional endpoints, set a custom base URL:"
echo " $ deepl config set api.baseUrl https://api-jp.deepl.com"
echo
echo " Custom/regional URLs always take priority over auto-detection."
echo
# Example 7: Reset configuration (demonstration only - not actually run)
echo "7. Reset configuration to defaults"
echo " ⚠️ Note: This example demonstrates the command but doesn't run it"
echo " because it would clear the API key and break subsequent examples."
echo
echo " To reset config in real usage:"
echo " $ deepl config reset"
echo
echo " After reset, you'll need to set your API key again:"
echo " $ deepl auth set-key YOUR_API_KEY"
echo
# ═══════════════════════════════════════════════════════
# AUTHENTICATION
# ═══════════════════════════════════════════════════════
echo "=== Authentication Commands ==="
echo
echo "8. Show current API key status:"
deepl auth show
echo
echo "9. Set API key from stdin (for scripts/CI):"
echo " echo \"YOUR_API_KEY\" | deepl auth set-key --from-stdin"
echo " deepl auth set-key --from-stdin < ~/.deepl-api-key"
echo
echo "10. Clear stored API key (not running - would break subsequent examples):"
echo " deepl auth clear"
echo
echo "=== All configuration examples completed! ==="
echo
echo "💡 Configuration tips:"
echo " - Config file location: ~/.config/deepl-cli/config.json"
echo " - Use defaults.targetLangs to avoid --to flag every time"
echo " - Disable cache if disk space is limited"
echo " - Endpoint is auto-detected from your API key; use api.baseUrl for regional endpoints"