mod char_;
mod detect_columns;
mod encode_decode;
mod format;
mod parse;
mod split;
mod str_;
pub use char_::Char;
pub use detect_columns::*;
pub use encode_decode::*;
pub use format::*;
use nu_engine::CallExt;
pub use parse::*;
pub use split::*;
pub use str_::*;
use nu_protocol::{
ast::Call,
engine::{EngineState, Stack, StateWorkingSet},
ShellError,
};
pub fn grapheme_flags(
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
) -> Result<bool, ShellError> {
let g_flag = call.has_flag(engine_state, stack, "grapheme-clusters")?;
if g_flag && call.has_flag(engine_state, stack, "utf-8-bytes")? {
Err(ShellError::IncompatibleParametersSingle {
msg: "Incompatible flags: --grapheme-clusters (-g) and --utf-8-bytes (-b)".to_string(),
span: call.head,
})?
}
if g_flag && call.has_flag(engine_state, stack, "code-points")? {
Err(ShellError::IncompatibleParametersSingle {
msg: "Incompatible flags: --grapheme-clusters (-g) and --utf-8-bytes (-b)".to_string(),
span: call.head,
})?
}
Ok(g_flag)
}
pub fn grapheme_flags_const(
working_set: &StateWorkingSet,
call: &Call,
) -> Result<bool, ShellError> {
let g_flag = call.has_flag_const(working_set, "grapheme-clusters")?;
if g_flag && call.has_flag_const(working_set, "utf-8-bytes")? {
Err(ShellError::IncompatibleParametersSingle {
msg: "Incompatible flags: --grapheme-clusters (-g) and --utf-8-bytes (-b)".to_string(),
span: call.head,
})?
}
if g_flag && call.has_flag_const(working_set, "code-points")? {
Err(ShellError::IncompatibleParametersSingle {
msg: "Incompatible flags: --grapheme-clusters (-g) and --utf-8-bytes (-b)".to_string(),
span: call.head,
})?
}
Ok(g_flag)
}