4 个版本
0.2.0 | 2024年3月17日 |
---|---|
0.1.2 | 2024年3月16日 |
0.1.1 | 2024年3月16日 |
0.1.0 | 2024年3月16日 |
#506 in Unix APIs
在 pacmanager 中使用
25KB
577 行
pacmanager_wrapper
- 一个用于管理软件包的通用库
一个用于与任何Linux发行版的包管理器交互的工具
包管理器支持
目前支持
- Apt
- Apk
- Yum
- Pacman
示例
摘自 examples/install.rs
use pacmanager_wrapper::{execute_action, PacManagerAction, PacManagerCommand};
use futures_lite::{io::BufReader, prelude::*};
#[tokio::main]
async fn main() {
// Create a PacManagerAction
let action = PacManagerAction {
pacmanager_command: PacManagerCommand::Install("lolcat".to_string()), // The action we want to do (which includes the package)
internal_config: Default::default(),
non_interactive: true,
custom_flags: None,
};
// Execute the action with APT and BufRead its output
let mut child = execute_action(action, pacmanager_wrapper::PacManager::Apt).await.unwrap();
let mut lines = BufReader::new(child.stdout.take().unwrap()).lines();
// Print out the PacManager's stdout
while let Some(line) = lines.next().await {
println!("{}", line.unwrap());
}
}
依赖项
~3–12MB
~149K SLoC