2020-02-08 22:13:56 +02:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
use crate::config::Config;
|
|
|
|
|
use crate::executor::RunType;
|
2020-03-08 21:38:49 +02:00
|
|
|
use crate::git::Git;
|
2020-02-08 22:13:56 +02:00
|
|
|
use directories::BaseDirs;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
pub struct ExecutionContext<'a> {
|
|
|
|
|
run_type: RunType,
|
|
|
|
|
sudo: &'a Option<PathBuf>,
|
2020-03-08 21:38:49 +02:00
|
|
|
git: &'a Git,
|
2020-02-08 22:13:56 +02:00
|
|
|
config: &'a Config,
|
|
|
|
|
base_dirs: &'a BaseDirs,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a> ExecutionContext<'a> {
|
|
|
|
|
pub fn new(
|
|
|
|
|
run_type: RunType,
|
|
|
|
|
sudo: &'a Option<PathBuf>,
|
2020-03-08 21:38:49 +02:00
|
|
|
git: &'a Git,
|
2020-02-08 22:13:56 +02:00
|
|
|
config: &'a Config,
|
|
|
|
|
base_dirs: &'a BaseDirs,
|
|
|
|
|
) -> ExecutionContext<'a> {
|
|
|
|
|
ExecutionContext {
|
|
|
|
|
run_type,
|
|
|
|
|
sudo,
|
2020-03-08 21:38:49 +02:00
|
|
|
git,
|
2020-02-08 22:13:56 +02:00
|
|
|
config,
|
|
|
|
|
base_dirs,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_type(&self) -> RunType {
|
|
|
|
|
self.run_type
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 21:38:49 +02:00
|
|
|
pub fn git(&self) -> &Git {
|
|
|
|
|
&self.git
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-08 22:13:56 +02:00
|
|
|
pub fn sudo(&self) -> &Option<PathBuf> {
|
|
|
|
|
&self.sudo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn config(&self) -> &Config {
|
|
|
|
|
&self.config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn base_dirs(&self) -> &BaseDirs {
|
|
|
|
|
&self.base_dirs
|
|
|
|
|
}
|
|
|
|
|
}
|