Function name

Source
pub fn name() -> Token
Expand description

Matches the name of a Thing found in the journal or recent entities.

§Examples

use initiative_core::command::prelude::*;

let query = "odysseus";
let token = name();
let odysseus = app_meta.repository.get_by_name("Odysseus").await.unwrap();
let token_match = token.match_input_exact(query, &app_meta).next().await.unwrap();

assert_eq!(TokenMatch::new(&token, odysseus.clone()), token_match);

// The matched Record can be accessed directly from the TokenMatch tree.
assert_eq!(Some(&odysseus), token_match.meta_record());

§Autocomplete

use initiative_core::command::prelude::*;

let query = "ody";
let token = name();
let odysseus = app_meta.repository.get_by_name("Odysseus").await.unwrap();

assert_eq!(
    Some(FuzzyMatch::Partial(
        TokenMatch::new(&token, odysseus),
        Some("sseus".to_string()),
    )),
    token.match_input(query, &app_meta).next().await,
);