rust/src/bin/rustfmt.rs

32 lines
985 B
Rust
Raw Normal View History

// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
2015-05-03 17:12:39 -05:00
#![cfg(not(test))]
extern crate rustfmt;
use rustfmt::{WriteMode, run};
2015-05-23 00:02:59 -05:00
use std::fs::File;
use std::io::Read;
fn main() {
let args: Vec<_> = std::env::args().collect();
2015-08-18 13:04:58 -05:00
let mut def_config_file = File::open("default.toml").unwrap_or_else(|e| {
panic!("Unable to open configuration file [default.toml] {}",e)
});
2015-05-23 00:02:59 -05:00
let mut def_config = String::new();
def_config_file.read_to_string(&mut def_config).unwrap();
run(args, WriteMode::Overwrite, &def_config);
2015-06-19 18:39:13 -05:00
std::process::exit(0);
}