diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index a7d3f4b..d6b2725 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ #![warn(clippy::get_unwrap)] #![allow(clippy::cognitive_complexity)] #![allow(clippy::missing_const_for_fn)] +#![allow(clippy::option_option)] #![allow(clippy::similar_names)] #![allow(clippy::struct_excessive_bools)] #![allow(clippy::too_many_arguments)] @@ -15,10 +16,11 @@ // just get a compilation failure #![allow(clippy::future_not_send)] +mod config; +mod dirs; mod env; mod format; mod info; -mod mutex; mod parse; mod prelude; mod runner; @@ -26,35 +28,40 @@ mod shell; use prelude::*; -#[derive(structopt::StructOpt)] -#[structopt(about = "NoteBook SHell")] +use clap::Parser as _; + +#[derive(clap::Parser)] +#[clap(about = "NoteBook SHell")] struct Opt { - #[structopt(short = "c")] + #[clap(short = 'c')] command: Option<String>, - #[structopt(long)] + #[clap(long)] status_fd: Option<std::os::unix::io::RawFd>, } -async fn async_main(opt: Opt) -> anyhow::Result<i32> { +#[tokio::main] +async fn async_main(opt: Opt) -> Result<i32> { if let Some(command) = opt.command { - let shell_write = opt.status_fd.and_then(|fd| { + let mut shell_write = opt.status_fd.and_then(|fd| { nix::sys::stat::fstat(fd).ok().map(|_| { // Safety: we don't create File instances for or read/write // data on this fd anywhere else - unsafe { async_std::fs::File::from_raw_fd(fd) } + unsafe { tokio::fs::File::from_raw_fd(fd) } }) }); - return runner::run(&command, shell_write.as_ref()).await; + return runner::main(command, &mut shell_write).await; } + #[cfg(nbsh_tokio_console)] + console_subscriber::init(); + shell::main().await } -#[paw::main] -fn main(opt: Opt) { - match async_std::task::block_on(async_main(opt)) { +fn main() { + match async_main(Opt::parse()) { Ok(code) => { std::process::exit(code); } |