pub mod editor;
pub mod editor_call_builder;
pub mod editor_kind;
pub mod errors;
use std::path::Path;
pub use editor::Editor;
pub use editor_call_builder::EditorCallBuilder;
pub use editor_kind::EditorKind;
use crate::errors::OpenEditorError;
static ENV_VARS: &[&str] = &["VISUAL", "EDITOR"];
macro_rules! impl_static_editor_methods {
(
$(
$(#[$doc:meta])*
$static_name:ident($($param:ident: $param_type:ty),*) -> $return_type:ty => $instance_method:ident
),* $(,)?
) => {
$(
$(#[$doc])*
pub fn $static_name($($param: $param_type),*) -> $return_type {
EditorCallBuilder::new().$instance_method($($param),*)
}
)*
};
}
impl_static_editor_methods! {
open_editor() -> Result<String, OpenEditorError> => open_editor,
edit_string(string: &str) -> Result<String, OpenEditorError> => edit_string,
edit_string_mut(string: &mut String) -> Result<(), OpenEditorError> => edit_string_mut,
open_file(file_path: &Path) -> Result<(), OpenEditorError> => open_file,
}