#![cfg_attr(windows, windows_subsystem = "windows")]
use std::env;
use std::process::ExitCode;
use clap::Parser;
use consolex::{self as cx, Mode};
#[derive(Parser)]
#[command(version)]
struct Cli {
#[arg(long, conflicts_with = "hide")]
show: bool,
#[arg(long)]
hide: bool,
}
fn main() -> ExitCode {
let raw: Vec<String> = env::args().skip(1).collect();
let mode: Mode = raw.iter().collect();
let created = match cx::init(mode) {
Ok(created) => created,
Err(e) => {
eprintln!("consolex: {e}");
return ExitCode::FAILURE;
}
};
let code = match Cli::try_parse() {
Ok(_cli) => {
println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
0
}
Err(e) => {
let code = if e.use_stderr() { 1 } else { 0 };
let _ = e.print();
code
}
};
if created {
let _ = cx::wait_key();
}
ExitCode::from(code as u8)
}