Skip to main content

get_groundstation/
get_groundstation.rs

1use lemonaid::CitraClient;
2use std::env;
3
4#[tokio::main]
5async fn main() {
6    // Get API key from environment variable
7    let api_key = env::var("CITRA_PAT")
8        .expect("CITRA_PAT environment variable not set");
9
10    // Create client
11    let client = CitraClient::new(&api_key, true);
12
13    // Get groundstation ID from command line argument if provided
14    let args: Vec<String> = env::args().collect();
15    
16    if args.len() >= 2 {
17        let groundstation_id = &args[1];
18        
19        // Test get_groundstation
20        println!("Fetching groundstation: {}", groundstation_id);
21        match client.get_groundstation(groundstation_id).await {
22            Ok(groundstation) => {
23                println!("\n✓ Success!");
24                println!("{:#?}", groundstation);
25            }
26            Err(e) => {
27                eprintln!("\n✗ Error: {}", e);
28                std::process::exit(1);
29            }
30        }
31        
32        println!("\n");
33    }
34
35    // Test list_groundstations
36    println!("Fetching all groundstations...");
37    match client.list_groundstations().await {
38        Ok(groundstations) => {
39            println!("\n✓ Found {} groundstation(s)", groundstations.len());
40            for groundstation in groundstations {
41                println!("  - {} ({}) at {}, {}", 
42                    groundstation.name, 
43                    groundstation.id,
44                    groundstation.latitude,
45                    groundstation.longitude
46                );
47            }
48        }
49        Err(e) => {
50            eprintln!("\n✗ Error: {}", e);
51        }
52    }
53}