Merge nucleic/sleek-thistle-egret-fyej into dev

This commit is contained in:
2026-07-18 05:19:31 -07:00
commit b6be87b72d
677 changed files with 102939 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
//! Experimental builtins.
#[cfg(feature = "builtin.save")]
mod save;
#[allow(unused_imports, reason = "not all builtins are used in all configs")]
use brush_core::builtins::{self, builtin, decl_builtin, raw_arg_builtin, simple_builtin};
/// Returns the set of experimental built-in commands.
pub fn experimental_builtins<SE: brush_core::extensions::ShellExtensions>()
-> std::collections::HashMap<String, builtins::Registration<SE>> {
let mut m = std::collections::HashMap::<String, builtins::Registration<SE>>::new();
#[cfg(feature = "builtin.save")]
m.insert("save".into(), builtin::<save::SaveCommand, SE>());
m
}
/// Extension trait that simplifies adding experimental builtins to a shell builder.
pub trait ShellBuilderExt {
/// Add experimental builtins to the shell being built.
#[must_use]
fn experimental_builtins(self) -> Self;
}
impl<SE: brush_core::extensions::ShellExtensions, S: brush_core::ShellBuilderState> ShellBuilderExt
for brush_core::ShellBuilder<SE, S>
{
fn experimental_builtins(self) -> Self {
self.builtins(crate::experimental_builtins())
}
}
+26
View File
@@ -0,0 +1,26 @@
use brush_core::{ExecutionResult, builtins};
use clap::Parser;
use std::io::Write;
/// (*EXPERIMENTAL*) Serializes the current shell state to JSON and writes it to stdout.
/// Beware that the serialized state may include sensitive information, such as any
/// secrets stored in shell variables or referenced in command history.
#[derive(Parser)]
pub(crate) struct SaveCommand {}
impl builtins::Command for SaveCommand {
type Error = brush_core::Error;
async fn execute<SE: brush_core::ShellExtensions>(
&self,
context: brush_core::ExecutionContext<'_, SE>,
) -> Result<ExecutionResult, Self::Error> {
let serialized_str = serde_json::to_string(&context.shell).map_err(|e| {
brush_core::Error::from(brush_core::ErrorKind::InternalError(e.to_string()))
})?;
writeln!(context.stdout(), "{serialized_str}")?;
Ok(ExecutionResult::success())
}
}