Crates.io | disfmt |
lib.rs | disfmt |
version | 0.1.1 |
source | src |
created_at | 2024-11-21 21:29:57.862893 |
updated_at | 2024-11-21 21:50:54.625039 |
description | Rust code disformatter |
homepage | |
repository | |
max_upload_size | |
id | 1456735 |
size | 16,062 |
disfmt
is a simple CLI tool for reformatting Rust code by aligning {
, }
, and ;
symbols vertically. It processes your code to improve readability by ensuring these symbols are consistently aligned across lines.
You can easily install disfmt
using Cargo, the Rust package manager.
cargo install disfmt
This will install the disfmt
command globally, allowing you to use it from anywhere in your terminal.
Once installed, you can use the disfmt
tool via the command line to process Rust code. Here's the basic usage:
disfmt input.rs -o output.rs
This will read the Rust code from input.rs
, align the {
, }
, and ;
symbols, and write the result to output.rs
.
You can also provide input through stdin and output the results to stdout:
cat input.rs | disfmt > output.rs
Or you can simply use:
disfmt input.rs
This will output the formatted code to the terminal (stdout).
-o <output>
: Specify the output file to save the formatted code. If not provided, the result will write to STDOUT
.input
: The input file to process. If not provided, the tool will read from STDIN
.fn parse_matches(matches: &clap::ArgMatches, cmd: &mut clap::Command, conn: &rusqlite::Connection) {
let subcommand = matches.subcommand().map_or_else(
|| {
cmd.print_help().ok() ;
std::process::exit(0) ;
} ,
|s| s ,
) ;
match subcommand.0 {
"add" => parse_add(matches, conn) ,
"list" => list_tasks_in_db(conn) ,
_ => {
eprintln!("Invalid subcommand") ;
cmd.print_help().ok() ;
std::process::exit(1) ;
If you'd like to contribute to disfmt
, feel free to fork the repository and submit pull requests! Please make sure to run the tests before submitting changes.
To build the project locally without installing, you can run:
cargo build --release
This project is licensed under the MIT License - see the LICENSE file for details.