MrPicklePinosaur / shrs

The rusty shell toolkit for hackers
https://mrpicklepinosaur.github.io/shrs/
Apache License 2.0
301 stars 24 forks source link

[Feature]: Make shell builder more ergonomic #466

Open MrPicklePinosaur opened 3 months ago

MrPicklePinosaur commented 3 months ago

What would you like to see added?

Currently a common pattern for shell builder is 1) initialize some state like Hooks 2) insert our data into the state we just defined 3) insert state into shell builder

As an example:

let mut hooks = Hooks::new();
hooks.insert(my_handler);
let myshell = ShellBuilder::default().with_hooks(hooks);

It would be more ergonomic to eliminate step 2) and provide a method on the shell builder directly to insert a hook, like:

let mut hooks = Hooks::new();
let myshell = ShellBuilder::default().insert_hook(my_handler);

and mirror similar functionality for other state/config.