diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-19 19:56:39 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-19 19:56:39 -0600 |
commit | ed686f7c7fdce0c3062a2859e32e974c096246df (patch) | |
tree | f8790403f1fa3648f9aae0826e1d9b31a4d8d502 /src | |
parent | a84e462b596c24d2562d766ceb019761085390c5 (diff) |
Add notes to eval output.
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/discocaml.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/commands/discocaml.rs b/src/commands/discocaml.rs index a24276d..2c34c81 100644 --- a/src/commands/discocaml.rs +++ b/src/commands/discocaml.rs @@ -56,12 +56,14 @@ pub enum DiscocamlCommand { /// [ "Expr" /// , { "expr": "1 + 2" /// , "has_redex": true +/// , "note": null /// } /// ] /// "#; /// let expected = DiscocamlResponse::Expr(DiscocamlResponseExpr { /// expr: "1 + 2".to_string(), /// has_redex: true, +/// note: None, /// }); /// /// let mut de = Deserializer::from_str(&example); @@ -83,6 +85,7 @@ pub enum DiscocamlResponse { pub struct DiscocamlResponseExpr { pub expr: String, pub has_redex: bool, + pub note: Option<String>, } impl DiscocamlResponseExpr { @@ -291,9 +294,18 @@ async fn run_dot(dot: &str) -> Result<BString> { } fn expr_response_message(expr: &DiscocamlResponseExpr) -> CreateInteractionResponseMessage { - // TODO: Real escaping + let mut msg = String::new(); + if let Some(note) = &expr.note { + msg.push_str(note); + msg.push('\n'); + } + msg.push_str("```ocaml\n"); + // TODO: Escaping + msg.push_str(&expr.expr); + msg.push_str("```\n"); + CreateInteractionResponseMessage::new() - .content(format!("```ocaml\n{}\n```", expr.expr)) + .content(msg) .button(CreateButton::new("draw-tree").label("Draw Tree")) .button( CreateButton::new("step-cbv") |