Skip to content

Commit 0e9dd31

Browse files
authored
Support scoop (#5)
1 parent 7b6d3d5 commit 0e9dd31

7 files changed

Lines changed: 34 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "upt"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["sigoden <sigoden@gmail.com>"]
55
edition = "2018"
66
description = "Universal package management tool for Windows, MacOS, Linux"

README-zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ brew install wget # upt可以像brew样工作
5555
- [x] apt
5656
- [x] brew
5757
- [x] choco
58+
- [x] scoop
5859
- [x] dnf
5960
- [x] pacman
6061
- [x] yum

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ brew install wget # upt will work like brew
5555
- [x] apt
5656
- [x] brew
5757
- [x] choco
58+
- [x] scoop
5859
- [x] dnf
5960
- [x] pacman
6061
- [x] yum

src/subcommand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl SubCommand {
130130
} else {
131131
options.remove(0)
132132
}
133-
},
133+
}
134134
false => {
135135
if operands.len() == 0 {
136136
String::new()

src/vendor.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
use std::fs;
2+
use std::process::{Command, Stdio};
3+
14
use crate::error::UptError;
25
use crate::subcommand::SubCommand;
36
use crate::task::Task;
4-
use std::fs;
57

68
mod apk;
79
mod apt;
810
mod brew;
911
mod choco;
1012
mod dnf;
1113
mod pacman;
14+
mod scoop;
1215
mod upt;
1316
mod yum;
1417

@@ -41,6 +44,7 @@ impl Vendor {
4144
"apt" => apt::init(),
4245
"brew" => brew::init(),
4346
"choco" => choco::init(),
47+
"scoop" => scoop::init(),
4448
"dnf" => dnf::init(),
4549
"pacman" => pacman::init(),
4650
"upt" => upt::init(),
@@ -52,6 +56,9 @@ impl Vendor {
5256
/// Detect package management on os
5357
pub fn detect() -> Result<Vendor, UptError> {
5458
if cfg!(target_os = "windows") {
59+
if which("scoop") {
60+
return Ok(scoop::init());
61+
}
5562
return Ok(choco::init());
5663
} else if cfg!(target_os = "macos") {
5764
return Ok(brew::init());
@@ -188,6 +195,14 @@ impl Vendor {
188195
}
189196
}
190197

198+
fn which(name: &str) -> bool {
199+
Command::new(name)
200+
.stdout(Stdio::null())
201+
.stderr(Stdio::null())
202+
.spawn()
203+
.is_ok()
204+
}
205+
191206
#[cfg(test)]
192207
mod tests {
193208
use super::*;

src/vendor/scoop.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
vendor! {
2+
name: "scoop",
3+
yes: [],
4+
install: "install $",
5+
remove: "uninstall $",
6+
upgrade: "update $",
7+
search: "search $",
8+
show: "info $",
9+
update_index: "update",
10+
upgrade_all: "update *",
11+
list_upgradable: "list",
12+
list_installed: "list",
13+
}

0 commit comments

Comments
 (0)