cargf - Linux


cargf (CARGo Format) is a tool for formatting CARGO files, the configuration files used by the CARGO package manager for Rust projects. It helps ensure consistency and readability, enhancing collaboration and maintainability.


cargf [options] [cargo-file]


  • cargo-file: (Optional) Path to the CARGO file to be formatted. Defaults to Cargo.toml if omitted.


  • -h, –help: Display help information.
  • -v, –version: Display version information.
  • -i, –in-place: Format the cargo file in-place, overwriting the original.
  • –max-width : Set the maximum line width for the formatted file. Defaults to 120.


Basic Formatting

Format the default CARGO file:


In-Place Formatting

Format and overwrite the CARGO file in-place:

cargf -i Cargo.toml

Custom Line Width

Format the CARGO file with a maximum line width of 100:

cargf --max-width 100 Cargo.toml

Common Issues

Incorrect CARGO File

Error: cargf: file not found

Solution: Ensure the specified cargo file exists and is accessible.

Parse Errors

Error: cargf: invalid TOML file

Solution: Check the CARGO file for syntax errors or invalid values.


cargf can be integrated into CI/CD pipelines or editor plugins to automate formatting and maintain file consistency.

Related Commands

  • cargo: The Rust package manager
  • rustup: Rust toolchain manager
  • rustfmt: Rust code formatter