Sort variable list when showing all variables.

Fixes #28
This commit is contained in:
projectmoon 2020-10-22 21:24:24 +00:00
parent c10ee5c0f3
commit 7f971703e2
1 changed files with 9 additions and 5 deletions

View File

@ -121,11 +121,15 @@ impl Command for GetAllVariablesCommand {
async fn execute(&self, ctx: &Context) -> Execution { async fn execute(&self, ctx: &Context) -> Execution {
let value = match ctx.db.get_user_variables(&ctx.room_id, &ctx.username).await { let value = match ctx.db.get_user_variables(&ctx.room_id, &ctx.username).await {
Ok(variables) => variables Ok(variables) => {
let mut variable_list = variables
.into_iter() .into_iter()
.map(|(name, value)| format!(" - {} = {}", name, value)) .map(|(name, value)| format!(" - {} = {}", name, value))
.collect::<Vec<_>>() .collect::<Vec<_>>();
.join("\n"),
variable_list.sort();
variable_list.join("\n")
}
Err(e) => format!("error getting variables: {}", e), Err(e) => format!("error getting variables: {}", e),
}; };