Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Nov 14, 2024
1 parent d612d08 commit 5c55b1f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ hostname = "0.4.0"
walkdir = "2.5.0"
toml_edit = "0.22.22"
which = '7.0.0'
tempfile = "3.14.0"

[dev-dependencies]
assert_cmd = "2.0.16"
Expand Down
25 changes: 20 additions & 5 deletions src/backends/winget.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::{BTreeMap, BTreeSet};
use std::io::Read;

use color_eyre::Result;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -28,15 +29,29 @@ impl Backend for WinGet {

fn query_installed_packages(_: &Config) -> Result<BTreeMap<String, Self::QueryInfo>> {
if !command_found("winget") {
log::warn!("winget command not found");
return Ok(BTreeMap::new());
}

let explicit = run_command_for_stdout(["winget", "list", "--id"], Perms::Same)?;
let mut tempfile = tempfile::NamedTempFile::new()?;

Ok(explicit
.lines()
.map(|x| (x.to_string(), WinGetQueryInfo {}))
.collect())
//TODO: refactor if https://github.com/microsoft/winget-cli/issues/184 or https://github.com/microsoft/winget-cli/issues/4267 are ever fixed
let explicit = run_command(
["winget", "export", tempfile.path().to_str().unwrap()],
Perms::Same,
)?;

let mut string = String::new();
tempfile.read_to_string(&mut string)?;
dbg!(string);

return Ok(BTreeMap::new());


// Ok(explicit
// .lines()
// .map(|x| (x.to_string(), WinGetQueryInfo {}))
// .collect())
}

fn install_packages(
Expand Down

0 comments on commit 5c55b1f

Please sign in to comment.