21个不稳定版本
0.11.2 | 2022年11月21日 |
---|---|
0.11.0 | 2022年7月9日 |
0.10.0 | 2021年9月21日 |
0.9.1 | 2021年1月20日 |
0.1.0 | 2019年3月22日 |
#872 in Unix API
15,841 每月下载量
用于 paru
30KB
666 行代码(不含注释)
aur-fetch
aur-fetch是一个用于管理从AUR下载和比较软件包的crate。这个过程被分解为多个不同的步骤,以提供最大程度的控制,并确保用户确认阅读后再合并软件包。
注意:此crate仅处理获取软件包。它假定传递给它的软件包列表是pkgbases,因此不能与拆分软件包一起工作。要处理拆分软件包,必须使用AUR RPC从pkgname获取pkgbase。
示例
打印 - 差异
use aur_fetch::Fetch;
let pkgs = vec!["discord", "spotify", "pacman-git"];
// Create our handle
let fetch = Fetch::new()?;
// Clone/Fetch the packages.
let fetched = fetch.download(&pkgs)?;
// Merge changes
fetch.merge(&fetched)?;
// Only diff packages that have not been reviewed
let to_diff = fetch.unseen(&pkgs)?;
// Print each diff
for (diff, pkg) in fetch.diff(&to_diff, true)?.iter().zip(pkgs.iter()) {
println!("{}:", pkg);
println!("{}", diff.trim());
}
差异视图
use aur_fetch::Fetch;
use std::process::Command;
let pkgs = vec!["discord", "spotify", "pacman-git"];
// Create our handle
let fetch = Fetch::new()?;
// Clone/Fetch the packages.
let fetched = fetch.download(&pkgs)?;
// Merge the changes.
fetch.merge(&fetched)?;
// Save diffs to cache.
fetch.save_diffs(&fetched)?;
// Make a view of the new files so we can easily see them in the file browser
let dir = fetch.make_view( "/tmp/aur_view", &pkgs, &fetched)?;
Command::new("vifm").arg("/tmp/aur_view").spawn()?.wait()?;
使用回调
use aur_fetch::Fetch;
let pkgs = vec!["discord", "spotify", "pacman-git"];
// Create our handle
let fetch = Fetch::new()?;
// Clone/Fetch the packages.
let feteched = fetch.download(&pkgs)?;
// Download the packages, printing downloads as they complete.
let fetched = fetch.download_cb(&pkgs, |cb| {
println!("Downloaded ({:0pad$}/{:0pad$}): {}", cb.n, pkgs.len(), cb.pkg, pad = 3);
})?;
// Merge the changes.
// In a real tool you would ask for user conformation before this
// As long as the changes are not merged this process can always be restarted and the diffs
// perserved
fetch.merge(&fetched)?;
依赖关系
~1.5MB
~51K SLoC