initiative_core/command/
about.rs1use crate::command::prelude::*;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
4pub struct About;
5
6impl Command for About {
7 fn token<'a>(&self) -> Token {
8 keyword("about")
9 }
10
11 fn autocomplete(
12 &self,
13 _fuzzy_match: FuzzyMatch,
14 _input: &str,
15 ) -> Option<AutocompleteSuggestion> {
16 Some(("about", "about initiative.sh").into())
17 }
18
19 fn get_priority(&self, _token_match: &TokenMatch) -> Option<CommandPriority> {
20 Some(CommandPriority::Canonical)
21 }
22
23 fn get_canonical_form_of(&self, _token_match: &TokenMatch) -> Option<String> {
24 Some("about".to_string())
25 }
26
27 async fn run(
28 &self,
29 _token_match: TokenMatch<'_>,
30 _app_meta: &mut AppMeta,
31 ) -> Result<String, String> {
32 Ok(include_str!("../../../data/about.md")
33 .trim_end()
34 .to_string())
35 }
36}
37
38#[cfg(test)]
39mod test {
40 use super::*;
41
42 use crate::test_utils as test;
43 use futures::StreamExt as _;
44
45 #[tokio::test]
46 async fn run_test() {
47 assert!(crate::command::run("about", &mut test::app_meta())
48 .await
49 .unwrap()
50 .contains("About initiative.sh"));
51 }
52
53 #[tokio::test]
54 async fn autocomplete_test() {
55 test::assert_autocomplete_eq!(
56 [("about", "about initiative.sh")],
57 About
58 .parse_autocomplete("a", &test::app_meta())
59 .collect()
60 .await,
61 );
62 }
63}