@@ -11,8 +11,44 @@ import (
1111 cliver "github.com/dl-alexandre/cli-tools/version"
1212)
1313
14+ // parseCacheSize parses cache size strings like "100MB", "1GB" to bytes.
15+ // Returns the size in bytes, or 0 if parsing fails.
16+ func parseCacheSize (sizeStr string ) int64 {
17+ if sizeStr == "" {
18+ return 0
19+ }
20+
21+ sizeStr = strings .TrimSpace (sizeStr )
22+ sizeStr = strings .ToUpper (sizeStr )
23+
24+ // Try to parse with suffix
25+ if strings .HasSuffix (sizeStr , "GB" ) {
26+ numStr := strings .TrimSuffix (sizeStr , "GB" )
27+ if num , err := strconv .ParseFloat (numStr , 64 ); err == nil {
28+ return int64 (num * 1024 * 1024 * 1024 )
29+ }
30+ } else if strings .HasSuffix (sizeStr , "MB" ) {
31+ numStr := strings .TrimSuffix (sizeStr , "MB" )
32+ if num , err := strconv .ParseFloat (numStr , 64 ); err == nil {
33+ return int64 (num * 1024 * 1024 )
34+ }
35+ } else if strings .HasSuffix (sizeStr , "KB" ) {
36+ numStr := strings .TrimSuffix (sizeStr , "KB" )
37+ if num , err := strconv .ParseFloat (numStr , 64 ); err == nil {
38+ return int64 (num * 1024 )
39+ }
40+ } else {
41+ // Try to parse as plain bytes
42+ if num , err := strconv .ParseInt (sizeStr , 10 , 64 ); err == nil {
43+ return num
44+ }
45+ }
46+
47+ return 0
48+ }
49+
1450func main () {
15- // Binary name is always cimis
51+ // Binary name is always cimis (set this BEFORE any version calls)
1652 cliver .BinaryName = "cimis"
1753
1854 // Start automatic update check in background (non-blocking)
@@ -94,59 +130,5 @@ func main() {
94130}
95131
96132func printUsage () {
97- fmt .Println (`Usage: cimis <command> [options]
98-
99- Commands:
100- version Show version information
101- check-updates Check for available updates
102- init Initialize database directories and metadata
103- fetch Fetch data from CIMIS API (DEPRECATED: use fetch-streaming)
104- fetch-streaming Fetch with optimized streaming + detailed metrics
105- ingest Fetch and store using streaming (production default)
106- ingest-opt Fetch and store using optimized streaming
107- query Query stored data
108- stats Show database statistics
109- verify Verify chunk integrity
110- profile CPU, memory, and performance profiling
111- register Open CIMIS registration page in browser
112- login Open CIMIS login page in browser
113- api-docs Open CIMIS API documentation in browser
114-
115- Global Options:
116- -data-dir string Data directory (default: ./data)
117- -app-key string CIMIS API app key (or CIMIS_APP_KEY env var)
118-
119- Examples:
120- # Check for updates
121- cimis check-updates
122-
123- # Force check for updates (bypass cache)
124- cimis check-updates -force
125-
126- # Initialize database
127- cimis init
128-
129- # Fetch recent data for station 2
130- cimis fetch -station 2 -days 30
131-
132- # Fetch multiple stations with streaming and detailed metrics
133- cimis fetch-streaming -stations 2,5,10 -year 2024 -concurrency 8 -perf
134-
135- # Ingest data for a specific year
136- cimis ingest -station 2 -year 2020
137-
138- # Query June 2020 data
139- cimis query -station 2 -start 2020-06-01 -end 2020-06-30
140-
141- # Query with caching and performance metrics
142- cimis query -station 2 -start 2020-06-01 -end 2020-06-30 -cache 100MB -perf
143-
144- # Open CIMIS registration page to get API key
145- cimis register
146-
147- # Open CIMIS login page
148- cimis login
149-
150- # Open CIMIS API documentation
151- cimis api-docs` )
133+ fmt .Println ("Usage: cimis <command> [options]" )
152134}
0 commit comments