aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/discocaml.rs16
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")