Skip to main content

command_surface/
traits.rs

1use crate::Glyph;
2use std::hash::Hash;
3
4pub trait Category: Copy + Eq + Hash + Glyph + 'static {
5    fn label(&self) -> &'static str;
6    fn order(&self) -> u8;
7
8    /// CLI prefix for commands in this category (e.g. "certmesh ", "mdns ").
9    /// Used by compact/stripped rendering to derive short command names.
10    fn cli_prefix(&self) -> &'static str {
11        ""
12    }
13
14    /// Short CLI name shown in overview mode (e.g. "certmesh", "mdns").
15    fn cli_name(&self) -> &'static str {
16        self.label()
17    }
18
19    /// One-line description of what this category does.
20    fn description(&self) -> &'static str {
21        ""
22    }
23}
24
25pub trait Tag: Copy + Eq + Hash + Glyph + 'static {
26    fn label(&self) -> &'static str;
27
28    /// Whether this tag conveys *actionable* information worth showing
29    /// prominently (destructive, elevated, streaming).  Non-highlight tags
30    /// (mutating, read-only, admin) are hidden in compact/highlight modes.
31    fn highlight(&self) -> bool {
32        true
33    }
34}
35
36pub trait Scope: Copy + Eq + Hash + Glyph + 'static {
37    fn label(&self) -> &'static str;
38
39    /// Whether this is the default/public scope.  Commands with the default
40    /// scope are shown first in compact summaries.
41    fn is_default(&self) -> bool {
42        true
43    }
44}