Skip to content

Commit

Permalink
feat: automaticlly select tool for unrecongized OS (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Dec 9, 2023
1 parent bd61e3e commit 8539d0e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Upt is just an advanced alias, relying on the platform's package management tool

## Features

### Unified Interface
### Unified command interface

Each operating system (OS) has its own package management tool, which requires different commands to complete the same operation.
This can be inconvenient when switching between or trying new OSs.
Expand Down Expand Up @@ -111,10 +111,7 @@ pacman -S vim # use pacman syntax
+------------------------------------------------------+----------------------+
```

Some platforms may support multiple package management tools, and upt defaults to selecting them in the order listed in the table.
Of course, you can also specify the `UPT_TOOL` environment variable.

For example, in Windows, `upt` will prioritize using `scoop`. If `scoop` is not available, it will use `choco`. If `choco` is also not available, it will use `winget`. If you set `UPT_TOOL=choco`, `choco` will be used even though `scoop` exists.
Some platforms may support multiple package management tools, and upt selects one of them in the order listed in the table.

## Install

Expand All @@ -130,7 +127,7 @@ cargo install upt

Download it from [GitHub Releases](https://github.com/sigoden/upt/releases), unzip and add aichat to your $PATH.

## CLI
## Usage

```
Usage:
Expand Down
5 changes: 4 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ impl fmt::Display for UptError {
NoVendor(v) => write!(f, "Vendor {} is not supported.", v),
NotSupportOS => write!(f, "Your OS is not supported currently."),
NotSupportTask => write!(f, "The task is not supported by your OS."),
NotFoundTool => write!(f, "No found package management tool."),
NotFoundTool => write!(
f,
"No found package management tool, use `$UPT_TOOL` to specify one."
),
InvalidSubcommand(v) => write!(f, "Invalid subcommand '{}'.", v),
InvalidArgs(v) => write!(f, "Invalid arguments.\n\n{}", v),
DisplyHelp(v) => write!(f, "{}", v),
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ macro_rules! tools {
$(
$os => vec![$($tool),+].into_iter().filter_map(|v| which_cmd(v)).collect(),
)+
_ => return Err(UptError::NotSupportOS),
_ => vec!["apt", "dnf", "pacman"],
};
match $crate::utils::find_tool(&tools) {
Some(tool) => $crate::vendor::init(&tool),
Expand Down

0 comments on commit 8539d0e

Please sign in to comment.