1use crate::Result;
2
3pub trait Command {
5 fn execute(&self) -> Result<String>;
7
8 fn name(&self) -> &'static str;
10
11 fn description(&self) -> &'static str;
13}
14
15pub trait DryRunnable: Command {
17 fn execute_dry_run(&self) -> Result<String>;
19
20 fn is_dry_run(&self) -> bool;
22}
23
24pub trait Destructive: Command {
26 fn destruction_description(&self) -> String;
28
29 fn confirm_destruction(&self) -> Result<bool> {
31 crate::core::safety::Safety::confirm_destructive_operation(
32 self.name(),
33 &self.destruction_description(),
34 )
35 }
36
37 fn create_backup(&self) -> Result<Option<String>> {
39 Ok(None) }
41}
42
43pub trait GitCommand: Command {
45 fn validate_git_repo(&self) -> Result<()> {
47 crate::core::validation::Validate::in_git_repo()
48 }
49
50 fn repo_root(&self) -> Result<String> {
52 crate::core::git::GitOperations::repo_root()
53 }
54
55 fn current_branch(&self) -> Result<String> {
57 crate::core::git::GitOperations::current_branch()
58 }
59}
60
61pub trait Interactive: Command {
63 fn is_interactive(&self) -> bool {
65 crate::core::interactive::Interactive::is_interactive()
66 }
67
68 fn execute_non_interactive(&self) -> Result<String>;
70}
71
72pub trait Formatter {
74 fn format(&self, content: &str) -> String;
76}
77
78pub trait Validator<T: ?Sized> {
80 fn validate(&self, input: &T) -> Result<()>;
82
83 fn validation_rules(&self) -> Vec<&'static str>;
85}
86
87pub trait Optimizable {
89 fn execute_optimized(&self) -> Result<String>;
91}
92
93pub trait MultiFormat: Command {
95 fn supported_formats(&self) -> Vec<&'static str>;
97
98 fn execute_with_format(&self, format: &str) -> Result<String>;
100}
101
102pub trait Configurable: Command {
104 type Config;
106
107 fn with_config(self, config: Self::Config) -> Self;
109}