Add new command for logging out of iamb session (#162)

This commit is contained in:
Aaditya Dhruv
2023-10-13 00:58:59 -05:00
committed by Ulyssa
parent b2b47ed7a0
commit 3b86be0545
4 changed files with 77 additions and 2 deletions

View File

@@ -471,6 +471,19 @@ fn iamb_open(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
return Ok(step);
}
fn iamb_logout(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
let args = desc.arg.strings()?;
if args.len() != 1 {
return Result::Err(CommandError::InvalidArgument);
}
let iact = IambAction::from(HomeserverAction::Logout(args[0].clone(), desc.bang));
let step = CommandStep::Continue(iact.into(), ctx.context.take());
return Ok(step);
}
fn add_iamb_commands(cmds: &mut ProgramCommands) {
cmds.add_command(ProgramCommand {
name: "cancel".into(),
@@ -557,6 +570,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
aliases: vec![],
f: iamb_editor,
});
cmds.add_command(ProgramCommand {
name: "logout".into(),
aliases: vec![],
f: iamb_logout,
});
}
/// Initialize the default command state.