disfmt

Crates.iodisfmt
lib.rsdisfmt
version0.1.1
sourcesrc
created_at2024-11-21 21:29:57.862893
updated_at2024-11-21 21:50:54.625039
descriptionRust code disformatter
homepage
repository
max_upload_size
id1456735
size16,062
Muxutruk (Muxutruk2)

documentation

README

disfmt

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.

Installation

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.

Usage

Once installed, you can use the disfmt tool via the command line to process Rust code. Here's the basic usage:

Aligning code from a file

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.

Aligning code from stdin

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).

Options

  • -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.

Example

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)                                                                       ;

Development

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.

Building the project

To build the project locally without installing, you can run:

cargo build --release

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

Commit count: 0

cargo fmt