Commit Graph

84 Commits

Author SHA1 Message Date
Mason Smith 764100361e cargo-fmt processes bench, test, example files 2016-11-02 02:28:06 -07:00
sinkuu a3c63fdef9 Run clippy 2016-08-29 08:57:27 +09:00
Daniel Campoverde 6380937b59 Multiple config file names feature (#1101)
* Add multiple configuration file names feature

* Add '.rustfmt.toml' in README file

* Clean up configuration file code

* Make config file names constant

* Use only one blank line
2016-08-01 09:32:35 +12:00
Nick Cameron ffa5a22d1c Merge pull request #1084 from johannhof/rustfmt-not-found
Show more helpful error if rustfmt is not in PATH.
2016-07-04 21:30:52 +12:00
Johann Hofmann 033741246c Show more helpful error if rustfmt is not in PATH.
This fixes #1071.
2016-07-04 07:42:18 +02:00
Nick Cameron ddda46d265 rustup 2016-07-04 15:46:58 +12:00
Johann Hofmann 8260d277c8 Return failure exit code on found diffs (fix #906)
This changes rustfmt to return exit code 4
when run with write mode diff and differences between
the formatted code and the original code are found.

Useful for CI to make sure your contributors actually ran rustfmt.
2016-06-21 23:01:15 +02:00
Kamal Marhubi 5361f61110 Include git commit and worktree status in version output (#1060)
This will help in debugging issues as rustfmt gets more users.

If the working tree is clean, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b)

If the working tree is dirty, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b worktree dirty)

If git is unavailable, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (git commit unavailable)

To avoid rebuilds on changing tests, the build script will only rerun if
files under src/ are changed. This means the actual git status may show
changed files and this would not show up in the version. This should not
be an issue as files not in src/ should not affect the build output.
2016-06-12 10:38:03 +02:00
Kamal Marhubi bef5d095a4 rustfmt: Add option to specify line ranges for formatting
This commit adds the `--experimental-file-lines` option to rustfmt. This
allows specifying line ranges to format from the command line.

Refs #434
2016-05-31 01:33:58 +02:00
Nick Cameron a9c3108c9c Change defaults and update tests and source
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-22 19:18:48 +12:00
Nick Cameron 9761cf71d8 Tests 2016-04-22 18:53:39 +12:00
Kamal Marhubi 27c91ee35b rustfmt: Parse options once instead of once per file argument (#944)
`update_config()` was parsing the `write-mode` option once for each file
argument. This commit parses them once up front into a `CliOptions`
struct, which is then applied to the config before calling `run()`.
2016-04-16 22:34:15 +02:00
Aleksey Kladov 77350e49b5 return non-zero exit code if there were errors 2016-04-15 02:51:50 +03:00
Kamal Marhubi 72427356eb rustfmt: Simplify match in project file lookup loop
This commit changes the match in `lookup_project_file` to use pattern
guards.
2016-04-10 18:42:55 -04:00
Kamal Marhubi fe5fa874da rustfmt: Make error handling more idiomatic
This commit replaces the `Operation::InvalidInput` variant with
`Result`, and uses the `try!()` macro instead of explicit matching.
2016-04-10 17:58:14 -04:00
Kamal Marhubi b55e50f387 rustfmt: Move getopts::Options creation to its own function 2016-04-10 17:57:44 -04:00
Srinivas Reddy Thatiparthy 901c5b1a5d use std::error instead std::out 2016-04-06 23:23:02 +05:30
Nick Cameron 4fdf859787 Merge pull request #897 from matklad/refactor-run
Refactor run family of functions
2016-04-05 11:25:13 +12:00
0x0G 6e393b3d53 Fix. rustfmt write to stderr instead stdout
Fix. rustfmt write to stderr instead stdout
2016-04-04 12:49:16 +02:00
Aleksey Kladov 84fb2f402e refactor: unify run and run_from_stdin 2016-04-02 22:24:38 +03:00
Aleksey Kladov c7e51d3994 minor: use enum instead of pair of booleans
This is a bit more typing, but statically forbids using both verbose and
quiet
2016-03-29 02:37:43 +03:00
Aleksey Kladov ac7778cc51 cargo-fmt: don't return zero on failure 2016-03-29 02:11:43 +03:00
Jason Dusek 867b5074aa Use braces, not parens, for macro def 2016-03-11 00:41:11 -08:00
Jason Dusek 223df90c81 Align arguments 2016-03-11 00:15:26 -08:00
Jason Dusek d216c358ef Write non-output to stderr when there is output 2016-03-11 00:15:26 -08:00
Kamal Marhubi de1fc319c1 rustfmt: Use struct-like enum variants for Operation 2016-03-02 13:08:08 -05:00
Kamal Marhubi 14dbac5fd7 config: Use write_mode from config
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
2016-02-08 22:52:44 -05:00
sid 46242ed10e Add support for the config-path option
Adds a config-path option for rustfmt. If this argument is provided,
it recursively searches the config-path for a rustfmt.toml file.
If file is not found, reverts to searching the file input path for the
config file or uses default options.
2016-02-02 15:08:44 +05:30
Kamal Marhubi 0f254bb343 docs: Clarify return type of lookup_project_file 2016-02-01 12:55:12 -05:00
Kamal Marhubi 98726d0a53 bin: Improve error handling in project file lookup
Previously errors were being silently ignored. Eg, if `rustfmt` did not
have permission to read a `rustfmt.toml` file, the default configuration
was used without informing the user.
2016-01-31 10:28:47 -05:00
Marcus Klaas de Vries 1d216e1829 Merge pull request #791 from kamalmarhubi/canonicalize-path
bin: Canonicalize path before looking for project file
2016-01-31 11:33:05 +01:00
Kamal Marhubi 7a0d8be405 bin: Canonicalize path before looking for project file 2016-01-31 02:01:54 -05:00
Kamal Marhubi bd9ad6b0a0 bin: Properly handle a directories named rustfmt.toml
`lookup_project_file` could erroneously find a *directory* named
`rustmfmt.toml` if there was one in its lookup path, and so ignore any
configuration file it should have found further up. The error handling
resulted in this silently using the default configuration.
2016-01-31 01:49:29 -05:00
Mark Story 0c9f27fe5e Start hacking checkstyle output in.
checkstyle now shows up on the option parser, and the code still
compiles/passes tests. Next up will be outputing the XML to stdout.
2016-01-13 20:59:18 -05:00
Victor M. Suarez 4f8938c616 Allow for setting of write-mode via config file. FIxes #215
Also from @marcusklaas:
 Refactor code output functions

 Specifically, `write_all_files` no longer returns a HashMap. It would sometimes
 contain items, and sometimes be empty. When "fixed" newlines are required, this
 must now be done with a separate call. The tests use this strategy and should now pass!
2016-01-12 18:12:48 -05:00
Aleksey Kladov a70b621607 add option to ignore out of line modules 2015-12-23 17:25:49 +03:00
Jan Likar a5da67f4c4 Add verbose and quiet flags to cargo-fmt
Quiet mode supresses rustfmt's stdout, verbose mode prints targets that
are going to be formatted.
2015-12-20 04:19:08 +01:00
Nick Cameron 0b5e6d57e5 Merge pull request #710 from JanLikar/master
Remove `--write-mode=replace` from cargo-fmt
2015-12-18 08:43:41 +13:00
Jan Likar c578ad8df5 Remove --write-mode=replace from cargo-fmt
Since replace is the default rustfmt write mode, there's no need to
call rustfmt with `--write-mode=replace`. As a bonus, it is now also
possible to override the write-mode.
2015-12-17 17:17:43 +01:00
Sean Marshallsay 7f21569351 Fix spelling mistake in cargo-fmt usage string. 2015-12-16 12:18:18 +00:00
Nick Cameron ecf12778fb Use replace rather than overwrite for cargo fmt 2015-12-16 18:07:59 +13:00
Jan Likar 1e5e290e39 Allow to pass arguments to rustfmt 2015-12-16 04:48:49 +01:00
Jan Likar 360f3efce8 Replace locate-project with read-manifest
Use `cargo read-manifest` instead of `cargo locate-project` to get
a list of files to be formatted.
2015-12-16 02:21:43 +01:00
Jan Likar 623277e7e0 Add cargo-fmt binary
Add a new utility, which formats all readable .rs files in the src
directory of the crate using rustfmt. Both binaries can be installed
using cargo install rustfmt. cargo-fmt can be used as a Cargo
subcommand - cargo fmt.
2015-12-14 15:50:19 +01:00
Nick Cameron 26297c56df Merge pull request #615 from JanLikar/version
Add --version switch
2015-12-07 07:32:16 +13:00
Manish Goregaokar f61ba91c2d Minor clippy fixes 2015-12-04 18:02:19 +05:30
Marcus Klaas 6e1f77664d Unwrap match arms that are simple blocks 2015-11-20 21:05:18 +01:00
Steven Fackler d7b331bea7 Use argv[0] for usage output
Usage messages traditionally use this as it contains the path that the
user provided to run the executable (e.g. `rustfmt` instead of
`/usr/local/bin/rustfmt`).
2015-11-19 17:56:37 -08:00
Jan Likar f85ff8d0e5 Print version of the crate
Print version acquired from Cargo when building. If built using rustc
directly, print X.X.X
2015-11-18 00:56:46 +01:00
Jan Likar 1eb38c461e Add -V as a shorthand for --version 2015-11-16 14:52:14 +01:00