systemprompt_cli/
descriptor.rs1#[derive(Debug, Clone, Copy, Default)]
2pub struct CommandDescriptor {
3 flags: u8,
4}
5
6impl CommandDescriptor {
7 const FLAG_PROFILE: u8 = 0b0000_0001;
8 const FLAG_SECRETS: u8 = 0b0000_0010;
9 const FLAG_PATHS: u8 = 0b0000_0100;
10 const FLAG_DATABASE: u8 = 0b0000_1000;
11 const FLAG_REMOTE_ELIGIBLE: u8 = 0b0001_0000;
12 const FLAG_SKIP_VALIDATION: u8 = 0b0010_0000;
13
14 pub const NONE: Self = Self { flags: 0 };
15
16 pub const PROFILE_ONLY: Self = Self {
17 flags: Self::FLAG_PROFILE,
18 };
19
20 pub const PROFILE_AND_SECRETS: Self = Self {
21 flags: Self::FLAG_PROFILE | Self::FLAG_SECRETS,
22 };
23
24 pub const PROFILE_SECRETS_AND_PATHS: Self = Self {
25 flags: Self::FLAG_PROFILE | Self::FLAG_SECRETS | Self::FLAG_PATHS,
26 };
27
28 pub const FULL: Self = Self {
29 flags: Self::FLAG_PROFILE
30 | Self::FLAG_SECRETS
31 | Self::FLAG_PATHS
32 | Self::FLAG_DATABASE
33 | Self::FLAG_REMOTE_ELIGIBLE,
34 };
35
36 pub const fn profile(&self) -> bool {
37 self.flags & Self::FLAG_PROFILE != 0
38 }
39
40 pub const fn secrets(&self) -> bool {
41 self.flags & Self::FLAG_SECRETS != 0
42 }
43
44 pub const fn paths(&self) -> bool {
45 self.flags & Self::FLAG_PATHS != 0
46 }
47
48 pub const fn database(&self) -> bool {
49 self.flags & Self::FLAG_DATABASE != 0
50 }
51
52 pub const fn remote_eligible(&self) -> bool {
53 self.flags & Self::FLAG_REMOTE_ELIGIBLE != 0
54 }
55
56 pub const fn skip_validation(&self) -> bool {
57 self.flags & Self::FLAG_SKIP_VALIDATION != 0
58 }
59
60 pub const fn with_remote_eligible(self) -> Self {
61 Self {
62 flags: self.flags | Self::FLAG_REMOTE_ELIGIBLE,
63 }
64 }
65
66 pub const fn with_skip_validation(self) -> Self {
67 Self {
68 flags: self.flags | Self::FLAG_SKIP_VALIDATION,
69 }
70 }
71}
72
73pub trait DescribeCommand {
74 fn descriptor(&self) -> CommandDescriptor;
75}