biolib 1.3.393

BioLib client library and CLI for running applications on BioLib
Documentation
use std::collections::HashMap;

fn main() {
    let app = biolib::load("test-team/hello-world:0.0.2").expect("Failed to load app");
    println!("Loaded app: {}", app.uri());

    let mut job = app.cli(None, None, None, true).expect("Failed to run app");

    let exit_code = job.get_exit_code().expect("Failed to get exit code");
    let stdout = job.get_stdout().expect("Failed to get stdout");
    let stderr = job.get_stderr().expect("Failed to get stderr");

    println!("Exit code: {exit_code}");
    println!("Stdout: {}", String::from_utf8_lossy(&stdout));
    if !stderr.is_empty() {
        eprintln!("Stderr: {}", String::from_utf8_lossy(&stderr));
    }

    let files = job.list_output_files().expect("Failed to list files");
    for file in &files {
        println!("Output file: {}", file.path);
    }
}

fn _example_with_args() {
    let app = biolib::load("test-team/hello-world:0.0.2").expect("Failed to load app");

    let args = vec!["--name".to_string(), "World".to_string()];
    let mut job = app
        .cli(Some(args), None, None, true)
        .expect("Failed to run app");

    println!(
        "Stdout: {}",
        String::from_utf8_lossy(&job.get_stdout().unwrap())
    );
}

fn _example_with_files() {
    let app = biolib::load("test-team/hello-world:0.0.2").expect("Failed to load app");

    let mut files = HashMap::new();
    files.insert("input.txt".to_string(), b"Hello from file".to_vec());

    let mut job = app
        .cli(None, None, Some(files), true)
        .expect("Failed to run app");

    let exit_code = job.get_exit_code().unwrap();
    println!("Exit code: {exit_code}");

    job.save_files("output_dir", true)
        .expect("Failed to save files");
}

fn _example_search() {
    let results = biolib::search(Some("hello"), None, 5).expect("Search failed");
    for uri in &results {
        println!("Found: {uri}");
    }
}

fn _example_get_result() {
    let job_id = "some-job-uuid";
    let mut job = biolib::get_result(job_id, None).expect("Failed to get result");

    let stdout = job.get_stdout().expect("Failed to get stdout");
    println!("Stdout: {}", String::from_utf8_lossy(&stdout));
}

fn _example_non_blocking() {
    let app = biolib::load("test-team/hello-world:0.0.2").expect("Failed to load app");

    let mut job = app
        .cli(None, None, None, false)
        .expect("Failed to start job");

    println!("Job ID: {}", job.id());
    println!("Share link: {}", job.get_shareable_link());

    job.wait(None).expect("Failed to wait for job");

    let exit_code = job.get_exit_code().unwrap();
    println!("Exit code: {exit_code}");
}