diff --git a/src/env.rs b/src/env.rs index 9811702..d10c9c7 100644 --- a/src/env.rs +++ b/src/env.rs @@ -9,7 +9,7 @@ pub(crate) struct Env { } impl Env { - pub(crate) fn main() -> Result { + pub(crate) fn main(args: impl Iterator>) -> Result { let dir = env::current_dir().context(error::CurrentDirectoryGet)?; let style = env::var_os("NO_COLOR").is_none() @@ -20,7 +20,7 @@ impl Env { Ok(Self::new( dir, - env::args(), + args, Box::new(io::stdin()), out_stream, err_stream, diff --git a/src/main.rs b/src/main.rs index 9ce15bd..3b116a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ fn main() { - if let Err(code) = imdl::run() { + if let Err(code) = imdl::run(std::env::args()) { std::process::exit(code); } } diff --git a/src/run.rs b/src/run.rs index 1325352..da0cb09 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,3 +1,9 @@ +//! `intermodal` is primarily used as a command-line binary, but does provide a +//! limited public library interface. +//! +//! Please keep in mind that there are no semantic version guarantees for the +//! library interface. It may break or change at any time. + use crate::common::*; /// Entry point into the IMDL binary. @@ -17,8 +23,8 @@ use crate::common::*; /// In case of an error, a nonzero status code is returned. This status code can /// be passed to `std::process::exit`, to exit the process and report its /// failure to the system. -pub fn run() -> Result<(), i32> { - let mut env = match Env::main() { +pub fn run(args: impl Iterator>) -> Result<(), i32> { + let mut env = match Env::main(args) { Ok(env) => env, Err(err) => { eprintln!("{err}");