gshell 1.0.1

gshell is a shell for people who live in the terminal. It pairs familiar Unix behavior with a tighter core, fast interaction, and an interface built to stay out of the way.
Documentation
use crate::{
    builtins::{Builtin, BuiltinFuture},
    shell::{CommandOutput, SharedShellState, ShellAction},
};

pub struct HistoryBuiltin;

impl Builtin for HistoryBuiltin {
    fn name(&self) -> &'static str {
        "history"
    }

    fn execute<'a>(&'a self, state: SharedShellState, _args: &'a [String]) -> BuiltinFuture<'a> {
        Box::pin(async move {
            let state = state.read().await;
            let mut stdout = String::new();

            for (i, entry) in state.history().entries().iter().enumerate() {
                stdout.push_str(&format!("{:>5} {}\n", i + 1, entry));
            }

            Ok(ShellAction::continue_with(CommandOutput {
                exit_code: crate::shell::ExitCode::SUCCESS,
                stdout,
                stderr: String::new(),
            }))
        })
    }
}