use std::collections::VecDeque;
use crate::PsScript;
pub struct PsScriptBuilder {
args: VecDeque<&'static str>,
no_profile: bool,
non_interactive: bool,
hidden: bool,
print_commands: bool,
}
impl PsScriptBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn no_profile(mut self, flag: bool) -> Self {
self.no_profile = flag;
self
}
pub fn non_interactive(mut self, flag: bool) -> Self {
self.non_interactive = flag;
self
}
pub fn hidden(mut self, flag: bool) -> Self {
self.hidden = flag;
self
}
pub fn print_commands(mut self, flag: bool) -> Self {
self.print_commands = flag;
self
}
pub fn build(self) -> PsScript {
let mut args = self.args;
if self.non_interactive {
args.push_front("-NonInteractive");
}
if self.no_profile {
args.push_front("-NoProfile");
}
PsScript {
args: args.make_contiguous().to_vec(),
hidden: self.hidden,
print_commands: self.print_commands,
}
}
}
impl Default for PsScriptBuilder {
fn default() -> Self {
let mut args = VecDeque::new();
args.push_back("-Command");
args.push_back("-");
Self {
args,
no_profile: true,
non_interactive: true,
hidden: true,
print_commands: false,
}
}
}