blob: 116add0a6564d7a32a81465f1feedc3c1ab0427a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) 2021 Soni L.
//
// Licensed under the MIT license.
// Documentation and comments licensed under CC BY-SA 4.0.
//! Iosonism is a command parsing library. It parses commands from strings, in
//! contrast with an argument parsing library, which parses arrays of strings.
//!
//! Iosonism is based on [Brigadier](https://github.com/Mojang/brigadier).
//!
//! This documentation is licensed under CC BY-SA 4.0. To view a copy of this
//! license, visit http://creativecommons.org/licenses/by-sa/4.0/
// quick overview of brigadier vs iosonism:
//
// - brigadier.StringReader -> iosonism::strcursor::StringReader + Cursor<&str>
// - brigadier.context.StringRange -> Range<usize>
// - brigadier.suggestion.Suggestion -> iosonism::suggestion::Suggestion;
// - brigadier.suggestion.Suggestions -> iosonism::suggestion::Suggestions;
// - brigadier.suggestion.SuggestionsBuilder -> iosonism::suggestion::SuggestionsBuilder;
pub mod args;
pub mod error;
pub mod strcursor;
pub mod suggestion;
pub mod tree;
use ::std::sync::Arc;
use crate::args::CommandContext;
/// Type of a command handler.
///
/// # Type params
///
/// - `T`: The type returned by the command.
/// - `S`: The source type accepted by this argument type.
/// - `E`: The error type accepted by this argument type.
pub type Command<Type, Source, Error> = Arc<
dyn for<'a, 'i> Fn(
&'a CommandContext<'i, Source, Error>
) -> Result<Type, Error> + Send + Sync
>;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
|