about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2017-05-01 15:15:30 +1200
committerGitHub <noreply@github.com>2017-05-01 15:15:30 +1200
commita8fbfdb4a3f3c0917e2d6a2dade42ec3f1580ca2 (patch)
tree52241c7c30c56e97d5d985bfe03ac5c93742320b
parent29e1a3329fc1e52f9e596fce8a9ec196a9cb3293 (diff)
parent0653b8413e11ea0a75fc86ea3ea08d54762ea594 (diff)
Merge pull request #1459 from shioju/master
Show exit codes' meanings with the rustfmt help message
-rw-r--r--Cargo.lock2
-rw-r--r--src/bin/rustfmt.rs1
-rw-r--r--src/summary.rs10
3 files changed, 12 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 54a26e545be..99d7721d442 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
 [root]
 name = "rustfmt"
-version = "0.8.2"
+version = "0.8.3"
 dependencies = [
  "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs
index 227ab849b3c..a802c3360ff 100644
--- a/src/bin/rustfmt.rs
+++ b/src/bin/rustfmt.rs
@@ -202,6 +202,7 @@ fn execute(opts: &Options) -> FmtResult<Summary> {
     match try!(determine_operation(&matches)) {
         Operation::Help => {
             print_usage(opts, "");
+            Summary::print_exit_codes();
             Ok(Summary::new())
         }
         Operation::Version => {
diff --git a/src/summary.rs b/src/summary.rs
index 5846afde7fc..6fc1bbded1d 100644
--- a/src/summary.rs
+++ b/src/summary.rs
@@ -63,4 +63,14 @@ impl Summary {
         self.has_parsing_errors |= other.has_parsing_errors;
         self.has_diff |= other.has_diff;
     }
+
+    pub fn print_exit_codes() {
+        let exit_codes = r#"Exit Codes:
+    0 = No errors
+    1 = Encountered operational errors e.g. an IO error
+    2 = Failed to reformat code because of parsing errors
+    3 = Code is valid, but it is impossible to format it properly
+    4 = Formatted code differs from existing code (write-mode diff only)"#;
+        println!("{}", exit_codes);
+    }
 }