Repository: casey/just
File: src/subcommand.rs (Rust)

Code before:
      .status();

    let status = match error {
      Err(io_error) => return Err(Error::EditorInvoke { editor, io_error }),
      Ok(status) => status,
    };

    if !status.success() {
      return Err(Error::EditorStatus { editor, status });
    }

    Ok(())
  }

  fn format(config: &Config, ast: Ast, src: &str, search: &Search) -> Result<(), Error<'static>> {
    config.require_unstable("The `--fmt` command is currently unstable.")?;

    if config.dry_run {
      let new_src = ast.to_string();
      if src != new_src {
        use prettydiff::diff_words;
        println!("Formatting diff:\n\n{}", diff_words(&src, &new_src));
        Err(Error::FormatCheckFoundDiff)
      } else {
        if config.verbosity.loud() {
          eprintln!("No format difference found.");
        }
        Ok(())
      }
    } else if let Err(io_error) =
      File::create(&search.justfile).and_then(|mut file| write!(file, "{}", ast))
    {
      Err(Error::WriteJustfile {
        justfile: search.justfile.clone(),
        io_error,
      })
    } else {
      if config.verbosity.loud() {
        eprintln!("Wrote justfile to `{}`", search.justfile.display());
      }
      Ok(())
    }
  }

  fn init(config: &Config) -> Result<(), Error<'static>> {
    let search = Search::init(&config.search_config, &config.invocation_directory)?;

    if search.justfile.is_file() {
      Err(Error::InitExists {
        justfile: search.justfile,
      })

Review comment (suggestion):
I think it's actually okay to not print anything in case of success. It's very common to use `rust fmt -- --check` and 
only check for the exit code.

```suggestion
```

Code after:
      .status();

    let status = match error {
      Err(io_error) => return Err(Error::EditorInvoke { editor, io_error }),
      Ok(status) => status,
    };

    if !status.success() {
      return Err(Error::EditorStatus { editor, status });
    }

    Ok(())
  }

  fn format(config: &Config, ast: Ast, src: &str, search: &Search) -> Result<(), Error<'static>> {
    config.require_unstable("The `--fmt` command is currently unstable.")?;

    let src_formatted = ast.to_string();
    if config.check {
      if src == src_formatted {
        Ok(())
      } else {
        print!(
          "{}",
          similar::udiff::unified_diff(similar::Algorithm::Patience, &src, &src_formatted, 2, None)
        );
        Err(Error::FormatCheckFoundDiff)
      }
    } else if let Err(io_error) =
      File::create(&search.justfile).and_then(|mut file| file.write_all(&src_formatted.as_bytes()))
    {
      Err(Error::WriteJustfile {
        justfile: search.justfile.clone(),
        io_error,
      })
    } else {
      if config.verbosity.loud() {
        eprintln!("Wrote justfile to `{}`", search.justfile.display());
      }
      Ok(())
    }
  }

  fn init(config: &Config) -> Result<(), Error<'static>> {
    let search = Search::init(&config.search_config, &config.invocation_directory)?;

    if search.justfile.is_file() {
      Err(Error::InitExists {
        justfile: search.justfile,
      })
    } else if let Err(io_error) = fs::write(&search.justfile, INIT_JUSTFILE) {