Function worterbuch_cli::app

source ·
pub fn app<'help>(
name: &'help str,
about: &'help str,
args: Vec<Arg<'help>>
) -> Result<(ArgMatches, String, String, u16, bool)>
Examples found in repository?
examples/last-will-test.rs (lines 12-16)
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
async fn main() -> Result<()> {
    dotenv::dotenv().ok();

    let (_matches, proto, host_addr, port, _json) = app(
        "last-will-test",
        "Test Wörterbuch's last will funciton.",
        vec![],
    )?;

    let on_disconnect = async move {
        log::warn!("Connection to server lost.");
        process::exit(1);
    };

    let mut con = connect(
        &proto,
        &host_addr,
        port,
        vec![("last_will/hello/world", json!("OFFLINE")).into()],
        vec![],
        on_disconnect,
    )
    .await?;

    con.set("last_will/hello/world".to_owned(), json!("ONLINE"))?;

    let mut lines = BufReader::new(tokio::io::stdin()).lines();
    while let Ok(Some(value)) = lines.next_line().await {
        con.set("last_will/hello/world".to_owned(), json!(value))?;
    }

    Ok(())
}