oxilean_codegen/bash_backend/
bashcondition_traits.rs1use super::types::BashCondition;
12use std::fmt;
13
14impl fmt::Display for BashCondition {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 match self {
17 BashCondition::FileExists(e) => write!(f, "[[ -e {} ]]", e),
18 BashCondition::IsFile(e) => write!(f, "[[ -f {} ]]", e),
19 BashCondition::IsDir(e) => write!(f, "[[ -d {} ]]", e),
20 BashCondition::NonEmpty(e) => write!(f, "[[ -n {} ]]", e),
21 BashCondition::Empty(e) => write!(f, "[[ -z {} ]]", e),
22 BashCondition::StrEq(a, b) => write!(f, "[[ {} == {} ]]", a, b),
23 BashCondition::StrNe(a, b) => write!(f, "[[ {} != {} ]]", a, b),
24 BashCondition::StrLt(a, b) => write!(f, "[[ {} < {} ]]", a, b),
25 BashCondition::ArithLt(a, b) => write!(f, "(( {} < {} ))", a, b),
26 BashCondition::ArithEq(a, b) => write!(f, "(( {} == {} ))", a, b),
27 BashCondition::And(a, b) => write!(f, "[[ {} && {} ]]", a, b),
28 BashCondition::Or(a, b) => write!(f, "[[ {} || {} ]]", a, b),
29 BashCondition::Not(c) => write!(f, "! {}", c),
30 BashCondition::Raw(s) => write!(f, "{}", s),
31 }
32 }
33}