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