@cakemail-org/cakemail-cli 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +12 -0
- package/.env.example +40 -0
- package/.env.test.example +45 -0
- package/CHANGELOG.md +1031 -0
- package/README.md +41 -37
- package/audit-formats.js +128 -0
- package/cakemail.rb +20 -0
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/account.js +1 -1
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/attributes.js +1 -1
- package/dist/commands/attributes.js.map +1 -1
- package/dist/commands/campaigns.js +1 -1
- package/dist/commands/campaigns.js.map +1 -1
- package/dist/commands/contacts.js +1 -1
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/emails.js +1 -1
- package/dist/commands/emails.js.map +1 -1
- package/dist/commands/interests.js +1 -1
- package/dist/commands/interests.js.map +1 -1
- package/dist/commands/lists.js +1 -1
- package/dist/commands/lists.js.map +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/reports.js +1 -1
- package/dist/commands/reports.js.map +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/segments.js.map +1 -1
- package/dist/commands/senders.js +1 -1
- package/dist/commands/senders.js.map +1 -1
- package/dist/commands/suppressed.js +1 -1
- package/dist/commands/suppressed.js.map +1 -1
- package/dist/commands/tags.js +1 -1
- package/dist/commands/tags.js.map +1 -1
- package/dist/commands/templates.js +1 -1
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/transactional-templates.js +1 -1
- package/dist/commands/transactional-templates.js.map +1 -1
- package/dist/commands/webhooks.js +1 -1
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/utils/config.js +2 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +32 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/spinner.d.ts +17 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +43 -0
- package/dist/utils/spinner.js.map +1 -0
- package/docs/DOCUMENTATION-STANDARD.md +1068 -0
- package/docs/README.md +161 -0
- package/docs/developer/ARCHITECTURE.md +516 -0
- package/docs/developer/AUTH.md +204 -0
- package/docs/developer/CONTRIBUTING.md +227 -0
- package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
- package/docs/developer/PROJECT_INDEX.md +365 -0
- package/docs/planning/API_COVERAGE.md +1045 -0
- package/docs/planning/BACKLOG.md +1159 -0
- package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
- package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
- package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
- package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
- package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
- package/docs/planning/cakemail-profile-system-plan.md +1121 -0
- package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
- package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
- package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
- package/docs/user-manual/.obsidian/app.json +1 -0
- package/docs/user-manual/.obsidian/appearance.json +1 -0
- package/docs/user-manual/.obsidian/core-plugins.json +33 -0
- package/docs/user-manual/.obsidian/workspace.json +167 -0
- package/docs/user-manual/01-getting-started/01-installation.md +214 -0
- package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
- package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
- package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
- package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
- package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
- package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
- package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
- package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
- package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
- package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
- package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
- package/docs/user-manual/03-email-operations/01-senders.md +490 -0
- package/docs/user-manual/03-email-operations/02-templates.md +444 -0
- package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
- package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
- package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
- package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
- package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
- package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
- package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
- package/docs/user-manual/05-contact-management/01-lists.md +836 -0
- package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
- package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
- package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
- package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
- package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
- package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
- package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
- package/docs/user-manual/07-integrations/02-automation.md +326 -0
- package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
- package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
- package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
- package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
- package/docs/user-manual/09-command-reference/01-config.md +776 -0
- package/docs/user-manual/09-command-reference/02-account.md +652 -0
- package/docs/user-manual/09-command-reference/03-lists.md +958 -0
- package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
- package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
- package/docs/user-manual/09-command-reference/06-segments.md +894 -0
- package/docs/user-manual/09-command-reference/07-senders.md +803 -0
- package/docs/user-manual/09-command-reference/08-templates.md +818 -0
- package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
- package/docs/user-manual/09-command-reference/10-emails.md +807 -0
- package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
- package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
- package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
- package/docs/user-manual/09-command-reference/14-interests.md +630 -0
- package/docs/user-manual/09-command-reference/15-tags.md +584 -0
- package/docs/user-manual/09-command-reference/16-logs.md +656 -0
- package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
- package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
- package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
- package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
- package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
- package/docs/user-manual/11-appendix/04-faq.md +484 -0
- package/docs/user-manual/11-appendix/05-glossary.md +250 -0
- package/docs/user-manual/README.md +0 -0
- package/package.json +13 -61
- package/src/cli.ts +125 -0
- package/src/client.ts +16 -0
- package/src/commands/account.ts +267 -0
- package/src/commands/accounts.ts +78 -0
- package/src/commands/actions.ts +249 -0
- package/src/commands/attributes.ts +139 -0
- package/src/commands/campaign-blueprints.ts +106 -0
- package/src/commands/campaigns.ts +469 -0
- package/src/commands/config.ts +77 -0
- package/src/commands/contacts.ts +612 -0
- package/src/commands/custom-attributes.ts +127 -0
- package/src/commands/dkims.ts +117 -0
- package/src/commands/domains.ts +82 -0
- package/src/commands/email-apis.ts +569 -0
- package/src/commands/emails.ts +197 -0
- package/src/commands/forms.ts +283 -0
- package/src/commands/interests.ts +155 -0
- package/src/commands/links.ts +38 -0
- package/src/commands/lists.ts +406 -0
- package/src/commands/logos.ts +71 -0
- package/src/commands/logs.ts +386 -0
- package/src/commands/reports.ts +306 -0
- package/src/commands/segments.ts +158 -0
- package/src/commands/senders.ts +204 -0
- package/src/commands/sub-accounts.ts +271 -0
- package/src/commands/suppressed-emails.ts +234 -0
- package/src/commands/suppressed.ts +198 -0
- package/src/commands/system-emails.ts +85 -0
- package/src/commands/tags.ts +146 -0
- package/src/commands/tasks.ts +116 -0
- package/src/commands/templates.ts +189 -0
- package/src/commands/tokens.ts +83 -0
- package/src/commands/transactional-emails.ts +374 -0
- package/src/commands/transactional-templates.ts +385 -0
- package/src/commands/users.ts +506 -0
- package/src/commands/webhooks.ts +172 -0
- package/src/commands/workflow-blueprints.ts +123 -0
- package/src/commands/workflows.ts +265 -0
- package/src/types/profile.ts +93 -0
- package/src/utils/auth.ts +272 -0
- package/src/utils/config-file.ts +96 -0
- package/src/utils/config.ts +134 -0
- package/src/utils/confirm.ts +32 -0
- package/src/utils/defaults.ts +99 -0
- package/src/utils/errors.ts +116 -0
- package/src/utils/interactive.ts +91 -0
- package/src/utils/list-defaults.ts +74 -0
- package/src/utils/output.ts +190 -0
- package/src/utils/progress.ts +320 -0
- package/src/utils/spinner.ts +22 -0
- package/tests/IMPLEMENTATION_STATUS.md +258 -0
- package/tests/PTY_SETUP.md +118 -0
- package/tests/PTY_TESTING_GUIDE.md +507 -0
- package/tests/README.md +244 -0
- package/tests/fixtures/api-responses/campaigns.json +34 -0
- package/tests/fixtures/test-config.json +13 -0
- package/tests/helpers/cli-runner.ts +128 -0
- package/tests/helpers/mock-server.ts +301 -0
- package/tests/helpers/pty-runner.ts +181 -0
- package/tests/integration/campaigns-real-api.test.ts +196 -0
- package/tests/integration/setup-integration.ts +50 -0
- package/tests/pty/campaigns.test.ts +241 -0
- package/tests/setup.ts +34 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
# Smart Defaults
|
|
2
|
+
|
|
3
|
+
Learn how the CLI automatically detects resources to streamline your workflow.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Smart Defaults (introduced) eliminate repetitive parameter inputs by auto-detecting common resources like lists and senders. If you have only one list or one confirmed sender, the CLI automatically uses it - no need to specify IDs every time!
|
|
8
|
+
|
|
9
|
+
**Key Benefits:**
|
|
10
|
+
- Zero-configuration workflow for users with single lists
|
|
11
|
+
- Fewer command-line parameters to remember
|
|
12
|
+
- Session caching for fast repeated operations
|
|
13
|
+
- Helpful suggestions when multiple resources exist
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## How Auto-Detection Works
|
|
18
|
+
|
|
19
|
+
When a command needs a list ID or sender ID, the CLI:
|
|
20
|
+
|
|
21
|
+
1. **Checks if parameter was provided** - If you specified `--list-id`, it uses that
|
|
22
|
+
2. **Looks in session cache** - Recent API calls are cached for 5 minutes
|
|
23
|
+
3. **Fetches from API** - If not cached, makes API call to list resources
|
|
24
|
+
4. **Auto-detects single resource** - If exactly one exists, uses it automatically
|
|
25
|
+
5. **Prompts or errors** - If multiple exist, shows options (interactive) or error (batch)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Commands with Auto-Detection
|
|
30
|
+
|
|
31
|
+
### List Auto-Detection (14 commands)
|
|
32
|
+
|
|
33
|
+
These commands make `list-id` optional when you have exactly one list:
|
|
34
|
+
|
|
35
|
+
**Contact Management:**
|
|
36
|
+
- `contacts list [list-id]` - List contacts
|
|
37
|
+
- `contacts add [list-id]` - Add contact
|
|
38
|
+
- `contacts export [list-id]` - Export contacts
|
|
39
|
+
- `contacts exports [list-id]` - List exports
|
|
40
|
+
|
|
41
|
+
**Segments:**
|
|
42
|
+
- `segments list [list-id]` - List segments
|
|
43
|
+
- `segments get [list-id] <segment-id>` - Get segment
|
|
44
|
+
- `segments create [list-id]` - Create segment
|
|
45
|
+
- `segments update [list-id] <segment-id>` - Update segment
|
|
46
|
+
- `segments delete [list-id] <segment-id>` - Delete segment
|
|
47
|
+
- `segments contacts [list-id] <segment-id>` - List segment contacts
|
|
48
|
+
|
|
49
|
+
**Custom Attributes:**
|
|
50
|
+
- `attributes list [list-id]` - List attributes
|
|
51
|
+
- `attributes get [list-id] <name>` - Get attribute
|
|
52
|
+
- `attributes create [list-id]` - Create attribute
|
|
53
|
+
- `attributes delete [list-id] <name>` - Delete attribute
|
|
54
|
+
|
|
55
|
+
### Sender Auto-Detection (1 command)
|
|
56
|
+
|
|
57
|
+
This command makes `sender-id` optional when you have exactly one confirmed sender:
|
|
58
|
+
|
|
59
|
+
- `campaigns create` - Auto-detects both list ID and sender ID
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Single Resource Scenario
|
|
64
|
+
|
|
65
|
+
When you have exactly one list (or sender), the CLI uses it automatically.
|
|
66
|
+
|
|
67
|
+
**Example: List Contacts (Single List)**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ cakemail contacts list
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Output:**
|
|
74
|
+
```
|
|
75
|
+
✓ Auto-detected list: 123 (Newsletter Subscribers)
|
|
76
|
+
|
|
77
|
+
┌──────────────────────┬────────────────────┬──────────────┐
|
|
78
|
+
│ Email │ Status │ Subscribed │
|
|
79
|
+
├──────────────────────┼────────────────────┼──────────────┤
|
|
80
|
+
│ john@example.com │ ✓ active │ 2 days ago │
|
|
81
|
+
│ jane@example.com │ ✓ active │ 5 days ago │
|
|
82
|
+
└──────────────────────┴────────────────────┴──────────────┘
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**What Happened:**
|
|
86
|
+
1. No `--list-id` provided
|
|
87
|
+
2. CLI fetched lists from API
|
|
88
|
+
3. Found exactly one list (ID: 123)
|
|
89
|
+
4. Used it automatically
|
|
90
|
+
5. Shows confirmation message
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Multiple Resources Scenario
|
|
95
|
+
|
|
96
|
+
When multiple lists exist, behavior depends on your profile and environment.
|
|
97
|
+
|
|
98
|
+
### Interactive Mode (Marketer/Balanced Profiles in TTY)
|
|
99
|
+
|
|
100
|
+
The CLI shows an interactive selection menu:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
$ cakemail contacts list
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Output:**
|
|
107
|
+
```
|
|
108
|
+
Multiple lists found. Please select one:
|
|
109
|
+
|
|
110
|
+
? Select a list:
|
|
111
|
+
❯ Newsletter Subscribers (1,234 contacts)
|
|
112
|
+
Product Updates (567 contacts)
|
|
113
|
+
VIP Customers (89 contacts)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
After selection, command proceeds with chosen list.
|
|
117
|
+
|
|
118
|
+
### Non-Interactive Mode (Developer Profile or Scripts)
|
|
119
|
+
|
|
120
|
+
The CLI returns an error with suggestions:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
$ cakemail contacts list
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Output:**
|
|
127
|
+
```
|
|
128
|
+
Error: Multiple lists found. Please specify --list-id <id>
|
|
129
|
+
|
|
130
|
+
Available lists:
|
|
131
|
+
123: Newsletter Subscribers (1,234 contacts)
|
|
132
|
+
456: Product Updates (567 contacts)
|
|
133
|
+
789: VIP Customers (89 contacts)
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
cakemail contacts list --list-id 123
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Solution:** Provide `--list-id`:
|
|
140
|
+
```bash
|
|
141
|
+
cakemail contacts list --list-id 123
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Session Caching
|
|
147
|
+
|
|
148
|
+
To improve performance, the CLI caches resource lookups for 5 minutes.
|
|
149
|
+
|
|
150
|
+
**How It Works:**
|
|
151
|
+
1. First call fetches lists from API
|
|
152
|
+
2. Result cached in memory
|
|
153
|
+
3. Subsequent calls within 5 minutes use cache
|
|
154
|
+
4. Cache expires after 5 minutes
|
|
155
|
+
|
|
156
|
+
**Example:**
|
|
157
|
+
```bash
|
|
158
|
+
# First call - fetches from API
|
|
159
|
+
$ cakemail contacts list
|
|
160
|
+
✓ Auto-detected list: 123
|
|
161
|
+
|
|
162
|
+
# Second call within 5 minutes - uses cache (instant)
|
|
163
|
+
$ cakemail segments list
|
|
164
|
+
✓ Auto-detected list: 123
|
|
165
|
+
|
|
166
|
+
# Third call within 5 minutes - uses cache (instant)
|
|
167
|
+
$ cakemail attributes list
|
|
168
|
+
✓ Auto-detected list: 123
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Benefits:**
|
|
172
|
+
- Faster command execution
|
|
173
|
+
- Reduced API calls
|
|
174
|
+
- Better user experience
|
|
175
|
+
- Lower API rate limit usage
|
|
176
|
+
|
|
177
|
+
**Cache Scope:**
|
|
178
|
+
- Per CLI session (process)
|
|
179
|
+
- Not persisted to disk
|
|
180
|
+
- Cleared after 5 minutes
|
|
181
|
+
- Separate for lists and senders
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Sender Auto-Detection
|
|
186
|
+
|
|
187
|
+
The `campaigns create` command auto-detects senders, but only confirmed ones.
|
|
188
|
+
|
|
189
|
+
### Single Confirmed Sender
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
$ cakemail campaigns create --name "Weekly Newsletter" --list-id 123
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Output:**
|
|
196
|
+
```
|
|
197
|
+
✓ Auto-detected sender: 456 (Marketing Team <marketing@company.com>)
|
|
198
|
+
✓ Campaign created: 789
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Multiple Confirmed Senders (Interactive)
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
$ cakemail campaigns create --name "Weekly Newsletter" --list-id 123
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Output:**
|
|
208
|
+
```
|
|
209
|
+
? Select a sender:
|
|
210
|
+
❯ Marketing Team <marketing@company.com> (Confirmed)
|
|
211
|
+
Sales Team <sales@company.com> (Confirmed)
|
|
212
|
+
Support <support@company.com> (Confirmed)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### No Confirmed Senders
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
$ cakemail campaigns create --name "Weekly Newsletter" --list-id 123
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Output:**
|
|
222
|
+
```
|
|
223
|
+
Error: No confirmed senders found. Please verify a sender first.
|
|
224
|
+
|
|
225
|
+
To create a sender:
|
|
226
|
+
cakemail senders create --name "Marketing Team" --email "marketing@company.com"
|
|
227
|
+
|
|
228
|
+
Then confirm via the email link sent to the sender address.
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Note:** Only **confirmed** senders are considered for auto-detection. Pending senders are excluded.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Disabling Auto-Detection
|
|
236
|
+
|
|
237
|
+
If you want to explicitly provide IDs every time, you have options:
|
|
238
|
+
|
|
239
|
+
### Option 1: Always Provide Parameters
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
cakemail contacts list --list-id 123
|
|
243
|
+
cakemail segments create --list-id 123 --name "Active Users"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Option 2: Use Developer Profile
|
|
247
|
+
|
|
248
|
+
Developer profile skips interactive prompts:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
cakemail config profile-set developer
|
|
252
|
+
cakemail contacts list # Error if list-id not provided
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Option 3: Use Batch Mode
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
cakemail --batch contacts list --list-id 123
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Best Practices
|
|
264
|
+
|
|
265
|
+
### 1. Let Auto-Detection Work
|
|
266
|
+
|
|
267
|
+
For single-list users, embrace auto-detection:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Good - simple and clear
|
|
271
|
+
cakemail contacts list
|
|
272
|
+
|
|
273
|
+
# Unnecessary - adds extra typing
|
|
274
|
+
cakemail contacts list --list-id 123
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 2. Provide IDs in Scripts
|
|
278
|
+
|
|
279
|
+
In automation, always provide IDs explicitly:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
#!/bin/bash
|
|
283
|
+
# Good - explicit and reliable
|
|
284
|
+
cakemail contacts export --list-id 123
|
|
285
|
+
|
|
286
|
+
# Avoid - depends on account state
|
|
287
|
+
cakemail contacts export
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 3. Use Cache for Repeated Operations
|
|
291
|
+
|
|
292
|
+
Group related commands together to benefit from caching:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# These all use the cached list lookup
|
|
296
|
+
cakemail contacts list
|
|
297
|
+
cakemail segments list
|
|
298
|
+
cakemail attributes list
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### 4. Profile-Aware Workflows
|
|
302
|
+
|
|
303
|
+
Choose profile based on your needs:
|
|
304
|
+
- **Marketer**: Interactive prompts when multiple resources exist
|
|
305
|
+
- **Balanced**: Interactive in terminal, error in scripts
|
|
306
|
+
- **Developer**: Always require explicit IDs
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## Troubleshooting
|
|
311
|
+
|
|
312
|
+
### "Multiple lists found" Error
|
|
313
|
+
|
|
314
|
+
**Problem:** Getting error even though you want to use a specific list
|
|
315
|
+
|
|
316
|
+
**Solution:** Provide `--list-id`:
|
|
317
|
+
```bash
|
|
318
|
+
cakemail contacts list --list-id 123
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Or switch to interactive profile:
|
|
322
|
+
```bash
|
|
323
|
+
cakemail config profile-set marketer
|
|
324
|
+
cakemail contacts list # Will show selection menu
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### Auto-Detection Not Working
|
|
330
|
+
|
|
331
|
+
**Problem:** CLI asks for list-id even though you have only one list
|
|
332
|
+
|
|
333
|
+
**Solutions:**
|
|
334
|
+
|
|
335
|
+
1. **Check you actually have lists:**
|
|
336
|
+
```bash
|
|
337
|
+
cakemail lists list
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
2. **Verify the parameter name:**
|
|
341
|
+
```bash
|
|
342
|
+
# Correct
|
|
343
|
+
cakemail contacts list
|
|
344
|
+
|
|
345
|
+
# Wrong - this command doesn't support auto-detection
|
|
346
|
+
cakemail lists get --list-id 123 # 'list-id' is required parameter here
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
3. **Clear and retry:**
|
|
350
|
+
Sometimes caching issues occur. Start a new terminal session.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### Unwanted Interactive Prompts
|
|
355
|
+
|
|
356
|
+
**Problem:** Getting prompts in scripts
|
|
357
|
+
|
|
358
|
+
**Solutions:**
|
|
359
|
+
|
|
360
|
+
1. **Use batch mode:**
|
|
361
|
+
```bash
|
|
362
|
+
cakemail --batch contacts list --list-id 123
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
2. **Switch to developer profile:**
|
|
366
|
+
```bash
|
|
367
|
+
cakemail config profile-set developer
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
3. **Always provide parameters:**
|
|
371
|
+
```bash
|
|
372
|
+
cakemail contacts list --list-id 123 --limit 100
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Commands That Don't Support Auto-Detection
|
|
378
|
+
|
|
379
|
+
These commands always require explicit IDs:
|
|
380
|
+
|
|
381
|
+
**Resource-Specific Operations:**
|
|
382
|
+
- `lists get <id>` - Specific list required
|
|
383
|
+
- `lists update <id>` - Specific list required
|
|
384
|
+
- `lists delete <id>` - Specific list required
|
|
385
|
+
- `campaigns get <id>` - Specific campaign required
|
|
386
|
+
- `senders get <id>` - Specific sender required
|
|
387
|
+
|
|
388
|
+
**Reason:** These operate on a specific resource, not a default one.
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Examples
|
|
393
|
+
|
|
394
|
+
### Example 1: Quick Contact Export
|
|
395
|
+
|
|
396
|
+
**Scenario:** Export contacts from your only list
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
# Old way (without smart defaults)
|
|
400
|
+
cakemail lists list # Find list ID
|
|
401
|
+
cakemail contacts export --list-id 123
|
|
402
|
+
|
|
403
|
+
# New way
|
|
404
|
+
cakemail contacts export
|
|
405
|
+
# ✓ Auto-detected list: 123 (Newsletter Subscribers)
|
|
406
|
+
# ✓ Export created: 456
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
### Example 2: Create Segment Workflow
|
|
412
|
+
|
|
413
|
+
**Scenario:** Create and populate a segment
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# All these commands use the same cached list
|
|
417
|
+
cakemail segments create --name "Active Users" --conditions "status==active"
|
|
418
|
+
# ✓ Auto-detected list: 123
|
|
419
|
+
|
|
420
|
+
cakemail segments list
|
|
421
|
+
# ✓ Auto-detected list: 123 (cached)
|
|
422
|
+
|
|
423
|
+
cakemail segments contacts 789
|
|
424
|
+
# ✓ Auto-detected list: 123 (cached)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
### Example 3: Multi-List Account
|
|
430
|
+
|
|
431
|
+
**Scenario:** Working with multiple lists interactively
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
# Marketer profile enables interactive selection
|
|
435
|
+
cakemail config profile-set marketer
|
|
436
|
+
|
|
437
|
+
cakemail contacts list
|
|
438
|
+
# ? Select a list:
|
|
439
|
+
# ❯ Newsletter (1,234 contacts)
|
|
440
|
+
# Product Updates (567 contacts)
|
|
441
|
+
|
|
442
|
+
# Choose "Newsletter" from menu
|
|
443
|
+
# [Shows Newsletter contacts]
|
|
444
|
+
|
|
445
|
+
cakemail segments list
|
|
446
|
+
# ? Select a list:
|
|
447
|
+
# ❯ Newsletter (1,234 contacts)
|
|
448
|
+
# Product Updates (567 contacts)
|
|
449
|
+
|
|
450
|
+
# Choose "Newsletter" again
|
|
451
|
+
# [Shows Newsletter segments]
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
### Example 4: Scripted Multi-List Operations
|
|
457
|
+
|
|
458
|
+
**Scenario:** Script that works with specific lists
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
#!/bin/bash
|
|
462
|
+
# Always provide list-id in scripts
|
|
463
|
+
|
|
464
|
+
NEWSLETTER_LIST=123
|
|
465
|
+
PRODUCT_LIST=456
|
|
466
|
+
|
|
467
|
+
# Export from both lists
|
|
468
|
+
cakemail contacts export --list-id $NEWSLETTER_LIST
|
|
469
|
+
cakemail contacts export --list-id $PRODUCT_LIST
|
|
470
|
+
|
|
471
|
+
echo "Exports created for both lists"
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Related Features
|
|
477
|
+
|
|
478
|
+
Smart Defaults work together with other CLI features:
|
|
479
|
+
|
|
480
|
+
- **[Profile System](/en/cli/core-concepts/profile-system/)** - Controls interactive vs non-interactive behavior
|
|
481
|
+
- **[Interactive Prompts](/en/cli/core-concepts/profile-system#interactive-prompts)** - Shows selection menus in interactive mode
|
|
482
|
+
- **Batch Mode** - Disables all auto-detection prompts
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|