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(
35 &self,
36 error: &error::Error,
37 shell: &Shell<impl extensions::ShellExtensions>,
38 ) -> String {
39 let _ = shell;
40 std::format!("error: {error:#}\n")
41 }
42}
43
44#[derive(Clone, Default)]
46pub struct DefaultErrorFormatter;
47
48impl ErrorFormatter for DefaultErrorFormatter {}
49
50pub trait PlaceholderBehavior: Clone + Default + Send + Sync + 'static {}
52
53#[derive(Clone, Default)]
55pub struct DefaultPlaceholder;
56
57impl PlaceholderBehavior for DefaultPlaceholder {}