53 lines
2.8 KiB
Rust
53 lines
2.8 KiB
Rust
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
|
|
fn check_edition(val: String, edition: &mut bool) -> String {
|
|
if val == "--edition" {
|
|
*edition = false;
|
|
}
|
|
|
|
val
|
|
}
|
|
|
|
pub fn main() {
|
|
let mut needs_edition = true;
|
|
let args = std::env::args()
|
|
.skip(1)
|
|
.map(|x| check_edition(x, &mut needs_edition))
|
|
.collect::<Vec<String>>();
|
|
|
|
let edition_args = if needs_edition {
|
|
vec!["--edition", "2024"]
|
|
} else {
|
|
vec![]
|
|
};
|
|
|
|
let yewfmt_args = edition_args
|
|
.into_iter()
|
|
.map(|x| x.into())
|
|
.chain(args)
|
|
.collect::<Vec<_>>();
|
|
|
|
if let Some(cmd) = option_env!("CARGO_BIN_FILE_YEW_FMT") {
|
|
let exit_code = std::process::Command::new(cmd)
|
|
.args(yewfmt_args)
|
|
.spawn()
|
|
.expect("Could not spawn process")
|
|
.wait()
|
|
.expect("Process did not start");
|
|
|
|
std::process::exit(exit_code.code().unwrap())
|
|
} else {
|
|
std::process::exit(1)
|
|
}
|
|
}
|