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 {
let value = match ctx.db.get_user_variables(&ctx.room_id, &ctx.username).await {
Ok(variables) => variables
.into_iter()
.map(|(name, value)| format!(" - {} = {}", name, value))
.collect::<Vec<_>>()
.join("\n"),
Ok(variables) => {
let mut variable_list = variables
.into_iter()
.map(|(name, value)| format!(" - {} = {}", name, value))
.collect::<Vec<_>>();
variable_list.sort();
variable_list.join("\n")
}
Err(e) => format!("error getting variables: {}", e),
};