shrs 0.0.6

modular library to build your own shell in rust
Documentation
//! Demonstration of conditional aliases
//!
//! If the user is in the home directory, the alias will evaluate to the command `true`, otherwise
//! the alias will evaluate to the command `false`

use shrs::prelude::*;

// TODO need better example, this one is pretty hacky
fn in_home_directory() -> bool {
    top_pwd() == "~"
}

fn main() {
    let mut alias = Alias::new();
    alias.set(
        "inhome",
        AliasInfo::with_rule("true", |_ctx| in_home_directory()),
    );
    alias.set(
        "inhome",
        AliasInfo::with_rule("false", |_ctx| !in_home_directory()),
    );

    let myshell = ShellBuilder::default().with_alias(alias).build().unwrap();

    myshell.run().unwrap();
}