tbrand / cargo-tomlfmt

Formatting Cargo.toml
https://crates.io/crates/cargo-tomlfmt
MIT License
30 stars 2 forks source link

Revamp client #28

Open flomonster opened 6 months ago

flomonster commented 6 months ago

The follow-up to this PR https://github.com/tbrand/cargo-tomlfmt/pull/22.

What is done:


[!NOTE] The command behavior is left unchanged

Before

$ cargo run -- --help

Formatting Cargo.toml

Usage: cargo-tomlfmt [OPTIONS] [COMMAND]

Commands:
  tomlfmt  It's just an alias as a subcommand of cargo.
  help     Print this message or the help of the given subcommand(s)

Options:
  -p, --path <path>  Path to the manifest. (default is Cargo.toml)
  -d, --dryrun       Do NOT overwrite the file.
  -k, --keep         Keep the original manifest as Cargo.toml.bak.
  -c, --create       Create a formatted manifest as Cargo.toml.new when dryrun.
  -h, --help         Print help
  -V, --version      Print version

Now

$ cargo run -- --help

Usage: cargo-tomlfmt [OPTIONS] [COMMAND]

Commands:
  tomlfmt  Just an alias as a subcommand of cargo
  help     Print this message or the help of the given subcommand(s)

Options:
  -p, --path <PATH>  Path to the manifest [default: Cargo.toml]
  -d, --dryrun       Do NOT overwrite the file
  -k, --keep         Keep the original manifest as Cargo.toml.bak
  -c, --create       Create a formatted manifest as Cargo.toml.new when dryrun
  -h, --help         Print help
  -V, --version      Print version

Create and Keep options behavior

Before

$ cargo tomlfmt -k -p sub_dir/Cargo.toml
$ ls sub_dir/Cargo.toml.bak
ls: cannot access 'sub_dir/Cargo.toml.bak': No such file or directory
$ ls Cargo.toml.bak # The backup file has changed folder
Cargo.toml.bak

Now

$ cargo tomlfmt -k -p sub_dir/Cargo.toml
$ ls sub_dir/Cargo.toml.bak # The backup file has the right path
sub_dir/Cargo.toml.bak
flomonster commented 6 months ago

Can I get a review @jayvdb