CLI

2 Posts

Publishing CLI tools, crates, and versions

6 minute

When a C project is shipped to other people, the hard part is often not whether the source builds. The hard part is the contract around it:

How is the tool installed into PATH?
Where do the headers and libraries go?
Which version should users link against?
Will an upgrade break existing code?
Does a public API change count as compatible?
Can the binary ABI remain stable over time?

Rust has the same questions, but the shipped object usually falls into one of three groups:

Read More

CLI Output and Exit Status

4 minute

Command-line output is not just printing text. For shells, CI, and other programs, the interface is often:

stdout   -> normal data
stderr   -> diagnostics and errors
exit code -> success or failure

C code commonly writes:

printf("%s\n", result);
fprintf(stderr, "tool: %s\n", error);
return 1;

Rust has the same boundaries, with a few ways to express them.

stdout Is for Normal Results

Simple output uses println!:

println!("{count}\t{path}");

It writes to stdout, which is what users and pipelines consume:

Read More