Skip to main content

run_cli

Function run_cli 

Source
pub fn run_cli<I>(args: I) -> ExitCode
where I: IntoIterator<Item: Into<OsString>>,
Expand description

Runs the command-line adapter and returns a process exit code.

This function is the stable entry point for the CLI adapter. It parses command-line arguments, dispatches the selected subcommand, writes output to the process streams, and converts adapter-specific failures into the documented numeric exit codes.

Standard output is flushed before returning, so a write that only fails when the buffer drains — a full disk, a quota, a reader that closed the pipe — is reported as exit code 5 instead of being discarded by the runtime’s exit-time flush.

§Examples

use truss::run_cli;

let _ = run_cli(vec![
    "truss".to_string(),
    "input.png".to_string(),
    "-o".to_string(),
    "output.jpg".to_string(),
]);
use truss::run_cli;

let _ = run_cli(vec![
    "truss".to_string(),
    "--bind".to_string(),
    "127.0.0.1:8080".to_string(),
]);