aboutsummaryrefslogtreecommitdiff
path: root/helix-dap/examples/dap-basic.rs
blob: 434f2eeb2856f63ece76aa555f3a8e9ed9fd9f2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use helix_dap::{Client, Result, SourceBreakpoint};

#[tokio::main]
pub async fn main() -> Result<()> {
    let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);

    let stderr_config = fern::Dispatch::new()
        .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
        .chain(std::io::stderr());

    base_config
        .chain(stderr_config)
        .apply()
        .expect("Failed to set up logging");

    let mut client = Client::start("nc", vec!["127.0.0.1", "7777"], 0)?;

    println!("init: {:?}", client.initialize().await);
    println!("caps: {:#?}", client.capabilities());
    println!(
        "launch: {:?}",
        client.launch("/tmp/godebug/main".to_owned()).await
    );

    println!(
        "breakpoints: {:#?}",
        client
            .set_breakpoints(
                "/tmp/godebug/main.go".to_owned(),
                vec![SourceBreakpoint {
                    line: 6,
                    column: Some(2),
                }]
            )
            .await
    );

    let mut _in = String::new();
    std::io::stdin()
        .read_line(&mut _in)
        .expect("Failed to read line");

    println!("configurationDone: {:?}", client.configuration_done().await);
    println!("stopped: {:?}", client.wait_for_stopped().await);
    println!("stack trace: {:#?}", client.stack_trace(1).await);

    let mut _in = String::new();
    std::io::stdin()
        .read_line(&mut _in)
        .expect("Failed to read line");

    println!("continued: {:?}", client.continue_thread(0).await);

    let mut _in = String::new();
    std::io::stdin()
        .read_line(&mut _in)
        .expect("Failed to read line");

    println!("disconnect: {:?}", client.disconnect().await);

    Ok(())
}