Skip to main content

xbp_cli/cli/
app.rs

1use std::path::PathBuf;
2
3/// Shared context passed into CLI handlers.
4#[derive(Debug, Clone)]
5pub struct AppContext {
6    debug: bool,
7    working_dir: PathBuf,
8}
9
10impl AppContext {
11    pub fn new(debug: bool) -> Self {
12        let working_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
13        Self { debug, working_dir }
14    }
15
16    pub fn debug(&self) -> bool {
17        self.debug
18    }
19
20    pub fn working_dir(&self) -> &PathBuf {
21        &self.working_dir
22    }
23}