cellos-ctl 0.5.2

cellctl — kubectl-style CLI for CellOS execution cells and formations. Thin HTTP client over cellos-server with apply/get/describe/logs/events/webui.
Documentation
//! `cellctl get formations` / `cellctl get cells` — list resources.
//!
//! Each subcommand corresponds to **exactly one** HTTP GET (Feynman's rule from
//! CHATROOM Session 16). Filters that the server understands (`?formation=`) are
//! forwarded as query params; nothing is filtered client-side.

use crate::client::CellosClient;
use crate::exit::CtlResult;
use crate::model::{Cell, Formation, List};
use crate::output::{self, OutputFormat};

pub async fn formations(client: &CellosClient, fmt: OutputFormat) -> CtlResult<()> {
    let list: List<Formation> = client.get_json("/v1/formations").await?;
    output::render_formations(&list.items, fmt);
    Ok(())
}

pub async fn cells(
    client: &CellosClient,
    formation: Option<&str>,
    fmt: OutputFormat,
) -> CtlResult<()> {
    let path = match formation {
        Some(f) => format!("/v1/cells?formation={}", urlencode(f)),
        None => "/v1/cells".to_string(),
    };
    let list: List<Cell> = client.get_json(&path).await?;
    output::render_cells(&list.items, fmt);
    Ok(())
}

fn urlencode(s: &str) -> String {
    url::form_urlencoded::byte_serialize(s.as_bytes()).collect()
}