Skip to main content

Crate bezant

Crate bezant 

Source
Expand description

bezant — command-line tool for the IBKR Client Portal Web API.

Wraps [bezant::Client] with a clap-powered CLI so ops / shell users can poke the Gateway without pulling in the Rust crate as a dependency.

Output format defaults to JSON (machine-readable, pipe-friendly). Pass --output table for a human-readable table on subcommands where one makes sense (positions, accounts, orders); the table renderer falls back to JSON for endpoints whose shape isn’t tabular (tickle, health).

Every subcommand prints to stdout on success and a non-zero exit on failure. Errors are printed to stderr as a one-line bezant: <message> followed by indented caused by: lines for each layer of the error chain.

§Environment

Env varDefaultMeaning
IBKR_GATEWAY_URLhttps://localhost:5000/v1/apiBase URL of the Client Portal Gateway
BEZANT_VERIFY_TLSfalseSet to true to enforce cert validation

Structs§

Cli 🔒

Enums§

Cmd 🔒
OutputFormat 🔒

Functions§

array_table 🔒
Render a JSON array of objects as a table whose columns are the supplied field names. Returns None when the body isn’t an array (caller falls back to JSON).
decode_json 🔒
fetch_json 🔒
Fetch a JSON body by building a path relative to the Gateway base URL.
kv_table 🔒
Render a JSON object as a 2-column “field / value” table.
main 🔒
paginated_positions 🔒
Walk pages of /portfolio/{id}/positions/{page} until a short page arrives or we hit the safety cap. Emits a stderr warning when the cap fires so the caller knows results were truncated — silently hitting MAX_POSITION_PAGES was a coverage gap flagged in review.
print_json 🔒
render 🔒
Render body either as JSON (always works) or via to_table if the caller supplied a tabular projection AND --output table was passed. to_table returns None when the endpoint shape doesn’t have a useful table form (e.g. tickle returns just a session id).
run 🔒
value_cell 🔒
Stringify a JSON value for table display. Strings without quotes, nulls as a literal “-” (so empty cells stand out), nested objects/arrays compact-JSON’d to keep rows readable.