refactor: put the dry-run and quiet checks on Ctx
This commit is contained in:
16
src/ctx.rs
16
src/ctx.rs
@@ -1,6 +1,22 @@
|
||||
use crate::cmd::Compose;
|
||||
use crate::fsops::Fs;
|
||||
|
||||
// how ahab was invoked, handed to everything that runs commands or writes files
|
||||
pub struct Ctx {
|
||||
pub verbose: bool,
|
||||
pub dry_run: bool,
|
||||
pub quiet: bool,
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
// the two things these flags actually decide, asked for by name rather than
|
||||
// read field by field wherever they are needed: a dry run writes nothing,
|
||||
// and --quiet stops compose narrating
|
||||
pub fn fs(&self) -> Fs<'_> {
|
||||
Fs::new(self)
|
||||
}
|
||||
|
||||
pub fn compose(&self) -> Compose<'_> {
|
||||
Compose::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user