cargo-wrap-comments-1.1.0 is not a library.
cargo-wrap-comments
A Rust command-line tool that formats source code comments to wrap long lines at a specified width. This does what rustfmt should do.
Features
- Wraps long comments to a configurable width (default: 100 characters)
- Reads
max_widthfrom.rustfmt.tomlorrustfmt.tomlif--max-widthis not specified - Combines consecutive comment lines before wrapping
- Supports Rust comment styles:
//,///,//! - Preserves indentation, comment markers, and blank comment lines
- Respects hierarchical markers (
#,*,-,1.,A.,a.), back-tick quoted text, and code blocks - Glob pattern support for processing multiple files
- Stdin/stdout mode when no files are specified
- Check mode for previewing changes without modifying files
Installation
From source
The binary will be at target/release/cargo-wrap-comments.
Usage
The tool can be run as a standalone command or as a Cargo subcommand:
# As a cargo subcommand
# As a standalone command
# Format comments in multiple files with glob patterns
# Set custom width
# Preview changes without modifying files
# Read from stdin, write to stdout
|
Options
| Option | Description | Default |
|---|---|---|
-w, --max-width N |
Maximum line width | 100 |
--check |
Preview mode, don't modify files | |
-v, --verbose |
Print verbose output | |
-q, --quiet |
Print less output | |
-V, --version |
Show version information | |
-h, --help |
Show help |
Comment Combining Rules
Consecutive comment lines are combined before wrapping when ALL of these are true:
- Same comment marker (
//,///, or//!) - Same indentation level
- Neither line is blank
- The next line does not start with a hierarchical marker:
#,*,-,```,1.,A.,a. - The current line does not contain a code fence marker (
```) - The current line does not start with
#(markdown heading lines are not combined with the text that follows)
Width Resolution
The line width is resolved in this order:
--max-width Non the command linemax_widthfrom.rustfmt.tomlorrustfmt.toml, searching from the current directory up to$HOME- Default: 100
The search stops at the first config file found. If it exists but has no max_width, the default is used.
Exit Codes
0— success1— one or more errors occurred (missing files, processing failures)