mirror of
https://github.com/GMGNAI/gmgn-skills.git
synced 2026-07-27 16:57:44 +00:00
fix(trenches): fix apiFieldToCliKey to match Commander.js camelCase for numeric suffixes
Commander.js removes hyphens before digits (e.g. -24h → 24h) but does not uppercase them. The previous regex only handled -[a-z] patterns, leaving a residual hyphen: minVolume-24h instead of minVolume24h. This caused all 24h-suffixed filter flags to be silently ignored: --min-volume-24h, --max-volume-24h, --min-net-buy-24h, --min-swaps-24h, --min-buys-24h, --min-sells-24h. Fix: add .replace(/-(\d)/g, '$1') to strip hyphens before digit sequences. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -290,13 +290,14 @@ const TRENCHES_FILTER_PRESETS: Record<string, Record<string, number | string>> =
|
||||
};
|
||||
|
||||
// Convert API snake_case field to Commander.js opts key
|
||||
// Commander.js camelCase: only converts -[a-z] patterns, digits stay as-is
|
||||
// e.g. min_volume_24h → min-volume-24h → minVolume-24h (digit prefix -24 is NOT converted)
|
||||
// e.g. min_smart_degen_count → min-smart-degen-count → minSmartDegenCount (all letters, converts fully)
|
||||
// Commander.js camelCase: converts -[a-z] to uppercase, and removes hyphen before digits
|
||||
// e.g. min_volume_24h → min-volume-24h → minVolume-24h → minVolume24h
|
||||
// e.g. min_smart_degen_count → min-smart-degen-count → minSmartDegenCount
|
||||
function apiFieldToCliKey(apiField: string): string {
|
||||
return apiField
|
||||
.replace(/_/g, '-')
|
||||
.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
|
||||
.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase())
|
||||
.replace(/-(\d)/g, '$1');
|
||||
}
|
||||
|
||||
// Client-side sort helpers (API does not support server-side sort for trenches)
|
||||
|
||||
Reference in New Issue
Block a user