1use crate::{Shell, error, extensions};
4
5pub trait ShellExtensions: Clone + Default + Send + Sync + 'static {
8 type ErrorFormatter: ErrorFormatter;
10}
11
12#[derive(Clone, Default)]
14pub struct ShellExtensionsImpl<EF: ErrorFormatter = DefaultErrorFormatter> {
15 _marker: std::marker::PhantomData<EF>,
16}
17
18impl<EF: ErrorFormatter> ShellExtensions for ShellExtensionsImpl<EF> {
19 type ErrorFormatter = EF;
20}
21
22pub type DefaultShellExtensions = ShellExtensionsImpl<DefaultErrorFormatter>;
25
26pub trait ErrorFormatter: Clone + Default + Send + Sync + 'static {
28 fn format_error(
36 &self,
37 error: &error::Error,
38 shell: &Shell<impl extensions::ShellExtensions>,
39 ) -> String {
40 let _ = shell;
41 std::format!("error: {error:#}\n")
42 }
43}
44
45#[derive(Clone, Default)]
47pub struct DefaultErrorFormatter;
48
49impl ErrorFormatter for DefaultErrorFormatter {}
50
51pub trait PlaceholderBehavior: Clone + Default + Send + Sync + 'static {}
53
54#[derive(Clone, Default)]
56pub struct DefaultPlaceholder;
57
58impl PlaceholderBehavior for DefaultPlaceholder {}