1#![cfg_attr(docsrs, feature(doc_auto_cfg))]
8#![warn(clippy::print_stderr)]
9#![warn(clippy::print_stdout)]
10
11#[derive(Debug)]
13pub struct Term {
14 width: u16,
15 height: u16,
16}
17
18#[allow(missing_docs)]
19impl Term {
20 pub fn new() -> Self {
21 Self {
22 width: 120,
23 height: 60,
24 }
25 }
26
27 pub fn width(mut self, width: u16) -> Self {
28 self.width = width;
29 self
30 }
31
32 pub fn height(mut self, height: u16) -> Self {
33 self.height = height;
34 self
35 }
36
37 pub fn get_width(&self) -> u16 {
38 self.width
39 }
40
41 pub fn get_height(&self) -> u16 {
42 self.height
43 }
44}
45
46impl Default for Term {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52pub trait RuntimeBuilder: std::fmt::Debug {
54 type Runtime: Runtime;
56
57 fn name() -> &'static str;
59
60 fn new(
62 bin_root: std::path::PathBuf,
63 home: std::path::PathBuf,
64 ) -> std::io::Result<Self::Runtime>;
65 fn with_home(
67 bin_root: std::path::PathBuf,
68 home: std::path::PathBuf,
69 ) -> std::io::Result<Self::Runtime>;
70}
71
72pub trait Runtime: std::fmt::Debug {
74 fn home(&self) -> &std::path::Path;
76
77 fn register(&mut self, name: &str, content: &str) -> std::io::Result<()>;
79
80 fn complete(&mut self, input: &str, term: &Term) -> std::io::Result<String>;
82}