miniximg_shell/lib.rs
1//! Interactive shell for [Minix v1 filesystem images][minix].
2//!
3//! `miniximg shell foo.img` drops into a REPL where paths default to the
4//! image. Anything prefixed with `@` is interpreted as a host path
5//! instead. Two working directories are tracked independently — `cd`
6//! changes the image-side cwd, `lcd` changes the host-side one — so the
7//! user can move around both filesystems in parallel.
8//!
9//! ```no_run
10//! use miniximg_shell::{run, ShellOptions};
11//! use std::path::PathBuf;
12//!
13//! run(ShellOptions {
14//! image: PathBuf::from("disk.img"),
15//! readonly: false,
16//! history: None,
17//! })?;
18//! # Ok::<(), anyhow::Error>(())
19//! ```
20//!
21//! Modifications are auto-committed to the image file as each command
22//! returns. Pass `readonly: true` to refuse every mutating command.
23//!
24//! [minix]: https://en.wikipedia.org/wiki/MINIX_file_system
25
26mod commands;
27mod editor;
28mod parser;
29mod path;
30mod session;
31
32pub use session::ShellOptions;
33
34use anyhow::Result;
35
36/// Run the interactive shell against the configured image, returning
37/// when the user issues `exit`, `quit`, or `Ctrl-D` on an empty line.
38pub fn run(options: ShellOptions) -> Result<()> {
39 let session = session::Session::open(options)?;
40 editor::run_repl(session)?;
41 Ok(())
42}