@@ -500,6 +500,7 @@ dependencies = [
"regex",
"rustyline",
"string-interner",
+ "titlecase",
"vergen",
]
@@ -993,6 +994,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
+[[package]]
+name = "titlecase"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f565e410cfc24c2f2a89960b023ca192689d7f77d3f8d4f4af50c2d8affe1117"
+dependencies = [
+ "lazy_static",
+ "regex",
+]
+
[[package]]
name = "unicode-bidi"
version = "0.3.7"
@@ -27,6 +27,7 @@ rustyline = "*"
ansi_term = "*"
string-interner = "*"
anyhow = "*"
+titlecase = "*"
[build-dependencies]
vergen = "*"
@@ -156,6 +156,14 @@ const BUILTINS: &[BuiltinFunc] = &[
Ok(Value::Lit(Literal::Str(s.as_str()?.to_uppercase())))
},
+ BuiltinFunc {
+ name: "capitalize",
+ callback: &|state: &State, expr: ExprRef, env: &Env| -> Result<Value, Error> {
+ let s = state.eval(expr, env)?;
+ Ok(Value::Lit(Literal::Str(titlecase::titlecase(s.as_str()?))))
+ },
BuiltinFunc {
name: "to-lower",
callback: &|state: &State, expr: ExprRef, env: &Env| -> Result<Value, Error> {