1use crate::cmd::Cmd;
2use std::fmt::{Display, Error, Formatter};
3
4impl Display for IOTCM {
5 fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
6 write!(
7 f,
8 "IOTCM {:?} {:?} {:?} {}",
9 self.file, self.level, self.method, self.command
10 )
11 }
12}
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16pub enum HighlightingLevel {
17 None,
18 NonInteractive,
19 Interactive,
23}
24
25impl Default for HighlightingLevel {
26 fn default() -> Self {
27 HighlightingLevel::NonInteractive
28 }
29}
30
31#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
33pub enum HighlightingMethod {
34 Direct,
36 Indirect,
38}
39
40impl Default for HighlightingMethod {
41 fn default() -> Self {
42 HighlightingMethod::Direct
43 }
44}
45
46#[derive(Debug, Clone)]
47pub struct IOTCM {
48 level: HighlightingLevel,
49 file: String,
50 method: HighlightingMethod,
51 pub command: Cmd,
52}
53
54impl IOTCM {
55 pub fn new(
56 level: HighlightingLevel,
57 file: String,
58 method: HighlightingMethod,
59 command: Cmd,
60 ) -> Self {
61 Self {
62 level,
63 file,
64 method,
65 command,
66 }
67 }
68
69 pub fn simple(file: String, command: Cmd) -> Self {
70 Self::new(Default::default(), file, Default::default(), command)
71 }
72
73 pub fn to_string(&self) -> String {
75 format!("{}\n", self)
76 }
77}