Add Sudo type (#221)

* Create `Sudo` type and `SudoKind` enum

* Fix build

* reformat

* Fix choco on windows

* Fix linux

* Fix linux more

* more fix stuff hehe hoho hahaha

* more fix stuff hehe hoho hahaha

Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com>
This commit is contained in:
Rebecca Turner
2022-11-25 17:19:32 -05:00
committed by GitHub
parent 526c4c9a58
commit b31778bdd8
10 changed files with 157 additions and 89 deletions

View File

@@ -19,17 +19,16 @@ pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
print_separator("Chocolatey");
let mut cmd = &choco;
let mut args = vec!["upgrade", "all"];
let mut command = match ctx.sudo() {
Some(sudo) => {
let mut command = ctx.run_type().execute(sudo);
command.arg(choco);
command
}
None => ctx.run_type().execute(choco),
};
if let Some(sudo) = ctx.sudo() {
cmd = sudo;
args.insert(0, "choco");
}
let mut command = ctx.run_type().execute(cmd);
command.args(&args);
command.args(["upgrade", "all"]);
if yes {
command.arg("--yes");