mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-16 10:40:12 +00:00
add missing -yes flags to command definitions, use log crate instead of printlns in command parser, also accept double dash for flags
This commit is contained in:
parent
8431255930
commit
12655fb539
16 changed files with 130 additions and 53 deletions
|
|
@ -16,6 +16,8 @@ lazy_static = { workspace = true }
|
|||
command_parser = { path = "../command_parser"}
|
||||
command_definitions = { path = "../command_definitions"}
|
||||
uniffi = { version = "0.29" }
|
||||
log = "0.4"
|
||||
simple_logger = "4.3.3"
|
||||
|
||||
[build-dependencies]
|
||||
uniffi = { version = "0.29", features = [ "build" ] }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
use std::{collections::HashMap, fmt::Write, sync::Arc};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::Write,
|
||||
sync::{Arc, Once},
|
||||
};
|
||||
|
||||
use command_parser::{parameter::ParameterValue, token::TokenMatchResult, Tree};
|
||||
|
||||
|
|
@ -14,6 +18,8 @@ lazy_static::lazy_static! {
|
|||
};
|
||||
}
|
||||
|
||||
static LOG_INIT: Once = Once::new();
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CommandResult {
|
||||
Ok { command: ParsedCommand },
|
||||
|
|
@ -121,6 +127,16 @@ pub struct ParsedCommand {
|
|||
}
|
||||
|
||||
pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
||||
LOG_INIT.call_once(|| {
|
||||
if let Err(err) = simple_logger::SimpleLogger::new()
|
||||
.with_level(log::LevelFilter::Info)
|
||||
.env()
|
||||
.init()
|
||||
{
|
||||
eprintln!("cant initialize logger: {err}");
|
||||
}
|
||||
});
|
||||
|
||||
command_parser::parse_command(COMMAND_TREE.clone(), prefix, input).map_or_else(
|
||||
|error| CommandResult::Err { error },
|
||||
|parsed| CommandResult::Ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue