crossbundle_tools/types/common/
config.rs1use super::Shell;
2use crate::error::Result;
3use std::cell::{RefCell, RefMut};
4use std::path::{Path, PathBuf};
5
6#[derive(Debug)]
9pub struct Config {
10 shell: RefCell<Shell>,
12 current_dir: PathBuf,
14}
15
16impl Config {
17 pub fn new(shell: Shell, current_dir: PathBuf) -> Config {
19 Config {
20 shell: RefCell::new(shell),
21 current_dir,
22 }
23 }
24
25 pub fn shell(&self) -> RefMut<'_, Shell> {
27 self.shell.borrow_mut()
28 }
29
30 pub fn status_message<T, U>(&self, status: T, message: U) -> Result<()>
32 where
33 T: std::fmt::Display,
34 U: std::fmt::Display,
35 {
36 self.shell().status_message(status, message)
37 }
38
39 pub fn status<T>(&self, status: T) -> Result<()>
41 where
42 T: std::fmt::Display,
43 {
44 self.shell().status(status)
45 }
46
47 pub fn current_dir(&self) -> &Path {
49 &self.current_dir
50 }
51}