feat: add --dry-run flag to all 47 CLI tools

When --dry-run is passed, each CLI prints the HTTP request it would
make (method, URL, headers, body) without actually calling fetch().
Auth credentials are masked as "***" in the output.

Useful for verifying request shape and API endpoints without needing
real API keys or making actual API calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Corey Haines
2026-02-17 11:47:12 -08:00
parent 3a85964305
commit 2c26f8497b
47 changed files with 250 additions and 43 deletions
+6
View File
@@ -14,6 +14,9 @@ async function trackApi(method, path, body) {
if (!WRITE_KEY) {
return { error: 'SEGMENT_WRITE_KEY required for tracking operations' }
}
if (args['dry-run']) {
return { _dry_run: true, method, url: `${TRACKING_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }
}
const auth = Buffer.from(`${WRITE_KEY}:`).toString('base64')
const res = await fetch(`${TRACKING_URL}${path}`, {
method,
@@ -35,6 +38,9 @@ async function profileApi(method, path) {
if (!ACCESS_TOKEN) {
return { error: 'SEGMENT_ACCESS_TOKEN required for profile operations' }
}
if (args['dry-run']) {
return { _dry_run: true, method, url: `${PROFILE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' } }
}
const auth = Buffer.from(`${ACCESS_TOKEN}:`).toString('base64')
const res = await fetch(`${PROFILE_URL}${path}`, {
method,