Commit graph

51 commits

Author SHA1 Message Date
Jiahao XU
68d111f946
Use get_desired_targets in entry
instead of `detect_targets`, so that if `opts.targets` is
`None`, the future returned by `detect_targets` can be run
in parallel by using `tokio::spawn` with other async code
in `entry`, such as `fetch_crate_cratesio`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 14:47:59 +10:00
Jiahao XU
c5a2a89361
Rm the duplicate debug! in main.rs:214
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-21 13:52:27 +10:00
Jiahao XU
24b1941c1a
Simplify fetch_crate_cratesio: Rm unused param temp_dir
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 17:09:17 +10:00
Jiahao XU
5bb5d12949
Optimize fetch_crate_cratesio using ManifestVisitor
and `download_tar_based_and_visit`.

By using these two items, we avoid any I/O altogether.
Everything happens in memory, thus there will be no i/o related errors
or cost.

This commit does not regress anything because
`helpers::load_manifest_path` calls `Manifest::from_path_with_metadata`,
which read in the whole `Cargo.toml` file at once.

Thus this commit would not cause any OOM when the the original code
would not.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 16:37:53 +10:00
Jiahao XU
88c3f15b3f
Rename Confirmer to UIThread
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-11 12:59:27 +10:00
Jiahao XU
47ed7ce27b
Use Confirmer instead of confirm in main.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-11 12:59:26 +10:00
Jiahao XU
728d1fd6dd
Rm unused param pkg_path in install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-09 14:47:43 +10:00
Jiahao XU
c9b0d45a24
Use download_and_extract in fetchers
to improve efficiency by avoiding disk io (except for `PkgFmt::Zip`
and `PkgFmt::Bin`) and run the compresser in parallel to the downloader.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-09 14:46:00 +10:00
Félix Saparelli
6333fb0bd3
Use newer format! syntax 2022-06-08 16:39:34 +12:00
Félix Saparelli
d0a292e173
Ignore rustls log output 2022-06-08 01:35:47 +12:00
Félix Saparelli
0abfcbd1fb
Simplify short help output 2022-06-08 01:04:46 +12:00
Félix Saparelli
235bcac300
Properly support multiple targets 2022-06-08 01:00:21 +12:00
Félix Saparelli
15d828b55b
Stop lying about url support 2022-06-08 00:54:30 +12:00
Félix Saparelli
f2582b9cf2
Expand help text 2022-06-08 00:11:39 +12:00
Félix Saparelli
d58ce3892a
Use clap3 2022-06-07 23:56:24 +12:00
Félix Saparelli
6877a0c3a9
Merge pull request #161 from NobodyXu/feature/bin-multi-targets 2022-06-07 23:55:05 +12:00
Jiahao XU
2ea341381d
Fix parsing in entry: Use std::env::args_os
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 17:07:17 +10:00
Jiahao XU
6f7c8fa8ab
Merge branch 'main' into feature/bin-multi-targets 2022-06-07 16:38:14 +10:00
Jiahao XU
ad3e707aa3
Fix install_from_package: Rm use of opts.target
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 16:37:04 +10:00
Jiahao XU
456e896483
Use code 17 for MainExit::JoinErr
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 16:22:01 +10:00
Jiahao XU
903c9f5591
Refactor: Use Result::map_or_else in main
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 16:19:07 +10:00
Jiahao XU
b6245bcf4b
Spawn entry() in main to improve parallelism
Using `rt.block_on`, the future returned by `entry` can only be run on
the main thread.

Buf if we use `tokio::spawn`, then it can be run on any thread.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 16:13:38 +10:00
Jiahao XU
c393270899
Run fetchers in parallel in MultiFetcher.first_available
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 15:29:09 +10:00
Jiahao XU
603955b848
Support for checking multi-targets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-07 15:11:04 +10:00
Félix Saparelli
ac74da4a27
Clippy suggestions 2022-06-01 01:11:26 +12:00
Félix Saparelli
529781a9a9
Format and link version mismatch warning 2022-06-01 00:29:18 +12:00
Félix Saparelli
7f0c818313
Don’t print "Fatal error" for UserAbort 2022-06-01 00:29:17 +12:00
Félix Saparelli
84ebc0039e
Pretty-print errors 2022-06-01 00:29:17 +12:00
Félix Saparelli
bd35c473a9
Use new Termination trait 2022-06-01 00:29:17 +12:00
Félix Saparelli
f56ed6fc4c
Add per-error exit codes 2022-06-01 00:29:17 +12:00
Félix Saparelli
c0eaffb05d
Refactor for rich errors, split user abort and genuine error 2022-06-01 00:29:14 +12:00
Lea Fairbanks
19d0616324
Add cli overrides 2022-05-31 18:00:07 +12:00
Félix Saparelli
e8464aba3d
Use tempfile over tempdir
Closes #135
2022-05-31 17:37:34 +12:00
Christof Weickhardt
42e327477b fix: abort install for specific version if not confirmed 2022-04-30 09:20:15 +00:00
Félix Saparelli
eeaba76b5f
Fallback to installing from source (#114)
Closes #108
2022-04-29 10:15:43 +12:00
Félix Saparelli
d68b0a209a
Clarify --version usage and add a warning at runtime (#116)
Fixes #113
2022-04-29 09:33:54 +12:00
Félix Saparelli
1757dc5344
Make fetcher creating infallible (#118)
Fixes #109
2022-04-29 09:24:46 +12:00
Félix Saparelli
b5d6d68d6d Fix quickinstall failing when packages are not wrapped in a folder 2022-02-16 22:42:37 +13:00
Félix Saparelli
5ef8abda3a Actually implement --dry-run 2022-02-16 17:16:29 +13:00
Félix Saparelli
370ae05620
QuickInstall support (#94)
See this issue: https://github.com/alsuren/cargo-quickinstall/issues/27

Quick Install is a hosted repo of built crates, essentially. The approach I've taken here is
a list of strategies:

1. First, we check the crate meta or default and build the URL to the repo. Once we have
   that, we perform a `HEAD` request to the URL to see if it's available.
2. If it's not, we build the URL to the quickinstall repo, and perform a `HEAD` to there.

As soon as we've got a hit, we use that. I've built it so it's extensible with more strategies.
This could be useful for #4.

This also adds a prompt before downloading from third-party sources, and logs a short
name for a source, which is easier to glance than a full URL, and includes a quick refactor
of the install/link machinery.
2022-02-16 14:49:07 +13:00
Félix Saparelli
0f9b4de449 Update deps 2021-11-17 21:53:20 +13:00
pinage404
6f05d630f0 fix: binary need to have the right to be executed 2021-10-17 12:35:15 +02:00
pinage404
90edbba221 fix: binary is not in a extracted folder 2021-10-17 12:34:36 +02:00
ryan
1c25b1346f added zip support, pkg-fmt override
swapped CI to build zips for windows
2021-04-08 18:39:54 +12:00
ryan
ef6a3d0ef7 fix version matching, now works with semver 2020-12-31 15:32:58 +13:00
ryan
a6c70b41e2 the big refactor 2020-12-31 14:41:52 +13:00
ryan
5fd78341c8 cleaning up binary logic, using standard [[bin]] definitions now 2020-12-31 13:19:58 +13:00
ryan
223c6ef43a playing with version matching
Can't use semver because crates.io hides alpha versions? not sure how this works in cargo
2020-12-30 18:13:38 +13:00
ryan
8777c355c5 swapped to symlink-based installation 2020-12-30 17:34:07 +13:00
ryan
8f7f7f5530 refactoring to library 2020-12-30 15:27:39 +13:00