Skip to main content

effective_directives

Function effective_directives 

Source
pub fn effective_directives(
    overrides: &[DirectiveDefinition],
) -> Vec<DirectiveDefinition>
Expand description

Complete directive table after applying the configuration overrides

Returns one definition per directive, in ReplDirective::ALL order: the override whose implementation matches when there is one, the default definition otherwise.

The configuration validator rejects two overrides of the same directive. On an unvalidated list, the last override of a directive wins.

ยงExample

use dynamic_cli::config::{effective_directives, DirectiveDefinition, ReplDirective};

let overrides = vec![DirectiveDefinition {
    implementation: ReplDirective::Help,
    name: "aide".to_string(),
    aliases: vec![],
    description: "Afficher l'aide".to_string(),
}];

let table = effective_directives(&overrides);
assert_eq!(table.len(), ReplDirective::ALL.len());
assert_eq!(table[0].name, "aide");
assert_eq!(table[2].name, "quit");