1use std::path::Path;
2use anyhow::Result;
3use apm_core::{config::Config, ticket::Ticket};
4
5pub struct CmdContext {
6 pub config: Config,
7 pub tickets: Vec<Ticket>,
8 pub aggressive: bool,
9}
10
11impl CmdContext {
12 pub fn load(root: &Path, no_aggressive: bool) -> Result<Self> {
13 let config = Config::load(root)?;
14 let aggressive = config.sync.aggressive && !no_aggressive;
15 crate::util::fetch_if_aggressive(root, aggressive);
16 let tickets = apm_core::ticket::load_all_from_git(root, &config.tickets.dir)?;
17 Ok(Self { config, tickets, aggressive })
18 }
19
20 pub fn load_config_only(root: &Path) -> Result<Config> {
21 Config::load(root)
22 }
23}