| @@ -422,6 +422,14 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { |
| 422 | } |
422 | } |
| 423 | |
423 | |
| 424 | let act: IambAction = match (field.as_str(), action.as_str(), args.pop()) { |
424 | let act: IambAction = match (field.as_str(), action.as_str(), args.pop()) { |
| |
425 | // :room dm set |
| |
426 | ("dm", "set", None) => RoomAction::SetDirect(true).into(), |
| |
427 | ("dm", "set", Some(_)) => return Result::Err(CommandError::InvalidArgument), |
| |
428 | |
| |
429 | // :room dm set |
| |
430 | ("dm", "unset", None) => RoomAction::SetDirect(false).into(), |
| |
431 | ("dm", "unset", Some(_)) => return Result::Err(CommandError::InvalidArgument), |
| |
432 | |
| 425 | // :room name set <room-name> |
433 | // :room name set <room-name> |
| 426 | ("name", "set", Some(s)) => RoomAction::Set(RoomField::Name, s).into(), |
434 | ("name", "set", Some(s)) => RoomAction::Set(RoomField::Name, s).into(), |
| 427 | ("name", "set", None) => return Result::Err(CommandError::InvalidArgument), |
435 | ("name", "set", None) => return Result::Err(CommandError::InvalidArgument), |
| @@ -789,6 +797,32 @@ mod tests { |
| 789 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
797 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
| 790 | } |
798 | } |
| 791 | |
799 | |
| |
800 | #[test] |
| |
801 | fn test_cmd_room_dm_set() { |
| |
802 | let mut cmds = setup_commands(); |
| |
803 | let ctx = EditContext::default(); |
| |
804 | |
| |
805 | let res = cmds.input_cmd("room dm set", ctx.clone()).unwrap(); |
| |
806 | let act = RoomAction::SetDirect(true); |
| |
807 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| |
808 | |
| |
809 | let res = cmds.input_cmd("room dm set true", ctx.clone()); |
| |
810 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
| |
811 | } |
| |
812 | |
| |
813 | #[test] |
| |
814 | fn test_cmd_room_dm_unset() { |
| |
815 | let mut cmds = setup_commands(); |
| |
816 | let ctx = EditContext::default(); |
| |
817 | |
| |
818 | let res = cmds.input_cmd("room dm unset", ctx.clone()).unwrap(); |
| |
819 | let act = RoomAction::SetDirect(false); |
| |
820 | assert_eq!(res, vec![(act.into(), ctx.clone())]); |
| |
821 | |
| |
822 | let res = cmds.input_cmd("room dm unset true", ctx.clone()); |
| |
823 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
| |
824 | } |
| |
825 | |
| 792 | #[test] |
826 | #[test] |
| 793 | fn test_cmd_room_tag_set() { |
827 | fn test_cmd_room_tag_set() { |
| 794 | let mut cmds = setup_commands(); |
828 | let mut cmds = setup_commands(); |