Skip to content

Commit

Permalink
refactor(commands/int_parser): return i32 instead of u32
Browse files Browse the repository at this point in the history
  • Loading branch information
radstevee committed Dec 29, 2024
1 parent 4870143 commit 5b737da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/commands/src/arg/parser/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl ArgumentParser for IntParser {
fn parse(&self, _ctx: Arc<CommandContext>, input: Arc<Mutex<CommandInput>>) -> ParserResult {
let token = input.lock().unwrap().read_string();

match token.parse::<u32>() {
match token.parse::<i32>() {
Ok(int) => Ok(Box::new(int)),
Err(err) => Err(error(err)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async fn arg_parse_test() {
#[tokio::test]
async fn parse_test() {
async fn test_executor(ctx: Arc<CommandContext>) -> CommandResult {
let num = ctx.arg::<u32>("number");
let num = ctx.arg::<i32>("number");
assert_eq!(num.to_string(), ctx.input.lock().unwrap().input);
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/default_commands/src/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ async fn root(ctx: Arc<CommandContext>) -> CommandResult {
async fn abc(ctx: Arc<CommandContext>) -> CommandResult {
let message = ctx.arg::<String>("message");
let word = ctx.arg::<String>("word");
let number = ctx.arg::<u32>("number");
let number = ctx.arg::<i32>("number");

ctx.reply(
TextComponentBuilder::new(format!(
"Message: {message:?}, Word: {word:?}, Message: {number}"
"Message: {message:?}, Word: {word:?}, Number: {number}"
))
.build(),
)
Expand Down

0 comments on commit 5b737da

Please sign in to comment.