mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-09 15:27:54 +00:00
format rust code
This commit is contained in:
parent
beec38ef8b
commit
d804303615
3 changed files with 59 additions and 49 deletions
|
|
@ -1,22 +1,23 @@
|
|||
use command_parser::{parse_command, Tree, command::Command, parameter::*, tokens};
|
||||
use command_parser::{Tree, command::Command, parameter::*, parse_command, tokens};
|
||||
|
||||
#[test]
|
||||
fn test_typoed_command_with_parameter() {
|
||||
let message_token = ("message", ["msg", "messageinfo"]);
|
||||
let author_token = ("author", ["sender", "a"]);
|
||||
|
||||
|
||||
// message <optional msg ref> author
|
||||
let cmd = Command::new(
|
||||
tokens!(message_token, Optional(MESSAGE_REF), author_token),
|
||||
"message_author"
|
||||
).help("Shows the author of a proxied message");
|
||||
|
||||
"message_author",
|
||||
)
|
||||
.help("Shows the author of a proxied message");
|
||||
|
||||
let mut tree = Tree::default();
|
||||
tree.register_command(cmd);
|
||||
|
||||
|
||||
let input = "message 1 auth";
|
||||
let result = parse_command(tree, "pk;".to_string(), input.to_string());
|
||||
|
||||
|
||||
match result {
|
||||
Ok(_) => panic!("Should have failed to parse"),
|
||||
Err(msg) => {
|
||||
|
|
@ -31,21 +32,18 @@ fn test_typoed_command_with_parameter() {
|
|||
fn test_typoed_command_with_flags() {
|
||||
let message_token = ("message", ["msg", "messageinfo"]);
|
||||
let author_token = ("author", ["sender", "a"]);
|
||||
|
||||
let cmd = Command::new(
|
||||
tokens!(message_token, author_token),
|
||||
"message_author"
|
||||
)
|
||||
.flag(("flag", ["f"]))
|
||||
.flag(("flag2", ["f2"]))
|
||||
.help("Shows the author of a proxied message");
|
||||
|
||||
|
||||
let cmd = Command::new(tokens!(message_token, author_token), "message_author")
|
||||
.flag(("flag", ["f"]))
|
||||
.flag(("flag2", ["f2"]))
|
||||
.help("Shows the author of a proxied message");
|
||||
|
||||
let mut tree = Tree::default();
|
||||
tree.register_command(cmd);
|
||||
|
||||
|
||||
let input = "message auth -f -flag2";
|
||||
let result = parse_command(tree, "pk;".to_string(), input.to_string());
|
||||
|
||||
|
||||
match result {
|
||||
Ok(_) => panic!("Should have failed to parse"),
|
||||
Err(msg) => {
|
||||
|
|
@ -54,4 +52,4 @@ fn test_typoed_command_with_flags() {
|
|||
assert!(msg.contains("message author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue