Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show toolchain list only once when the -i/--installed flag is provided #86

Closed
marcospb19 opened this issue Dec 29, 2022 · 2 comments · Fixed by #87 or #88
Closed

Show toolchain list only once when the -i/--installed flag is provided #86

marcospb19 opened this issue Dec 29, 2022 · 2 comments · Fixed by #87 or #88
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We'd appreciate someone creating a PR to address this

Comments

@marcospb19
Copy link
Collaborator

marcospb19 commented Dec 29, 2022

Here's the output of running cargo sweep -r -i:

[INFO] Using all installed toolchains: ["stable-2022-09-22-x86_64-unknown-linux-gnu", "stable-x86_64-unknown-linux-gnu", "nightly-2022-06-20-x86_64-unknown-linux-gnu", "nightly-2022-08-06-x86_64-unknown-linux-gnu", "nightly-x86_64-unknown-linux-gnu", "1.35.0-x86_64-unknown-linux-gnu", "1.57.0-x86_64-unknown-linux-gnu", "1.58.1-x86_64-unknown-linux-gnu", "1.59.0-x86_64-unknown-linux-gnu", "1.60.0-x86_64-unknown-linux-gnu", "1.61.0-x86_64-unknown-linux-gnu", "1.63.0-x86_64-unknown-linux-gnu", "1.64.0-x86_64-unknown-linux-gnu", "1.65.0-x86_64-unknown-linux-gnu"]
[INFO] Cleaned 0.00 bytes from "/home/marcospb19/PROJECT_1/target"
[INFO] Using all installed toolchains: ["stable-2022-09-22-x86_64-unknown-linux-gnu", "stable-x86_64-unknown-linux-gnu", "nightly-2022-06-20-x86_64-unknown-linux-gnu", "nightly-2022-08-06-x86_64-unknown-linux-gnu", "nightly-x86_64-unknown-linux-gnu", "1.35.0-x86_64-unknown-linux-gnu", "1.57.0-x86_64-unknown-linux-gnu", "1.58.1-x86_64-unknown-linux-gnu", "1.59.0-x86_64-unknown-linux-gnu", "1.60.0-x86_64-unknown-linux-gnu", "1.61.0-x86_64-unknown-linux-gnu", "1.63.0-x86_64-unknown-linux-gnu", "1.64.0-x86_64-unknown-linux-gnu", "1.65.0-x86_64-unknown-linux-gnu"]
[INFO] Cleaned 0.00 bytes from "/home/marcospb19/PROJECT_2/target"
... repeats for a total of 26 projects ...

But here's what the first line looks like in the terminal emulator:

[INFO] Using all installed toolchains: ["stable-2022-09-22-x86_64-unknown-linux-gnu", "stable-x86_64-unknown-linux-gnu", "nightly-2022-06-20-x86_64-unknown-linux-gnu", "nightly-2022-08-06-x86_64-unknown-linux-gnu", "nightly-x86_64-unknown-linux-gnu", "1.35.0-x86_64-unknown-linux-gnu", "1.57.0-x86_64-unknown-linux-gnu", "1.58.1-x86_64-unknown-linux-gnu", "1.59.0-x86_64-unknown-linux-gnu", "1.60.0-x86_64-unknown-linux-gnu", "1.61.0-x86_64-unknown-linux-gnu", "1.63.0-x86_64-unknown-linux-gnu", "1.64.0-x86_64-unknown-linux-gnu", "1.65.0-x86_64-unknown-linux-gnu"]

My home dir has 26 projects, so this gets shown 26 times, making the output unreadable.


IMHO the toolchain list should be shown only once if the -i/--installed flag is provided.

@jyn514
Copy link
Collaborator

jyn514 commented Dec 30, 2022

Yes, makes sense to me :) I think the way to avoid this is to move this rustup_toolchain_list call:

match rustup_toolchain_list() {
Some(list) => {
info!("Using all installed toolchains: {:?}", list);
lookup_from_names(list.iter().map(Some))?
}
None => {
info!("Couldn't identify the installed toolchains, using bare `rustc` call");
let list: Vec<Option<String>> = vec![None];

out of the project loop:

cargo-sweep/src/main.rs

Lines 250 to 252 in 42cf364

if matches.is_present("installed") || matches.is_present("toolchains") {
for project_path in &paths {
match remove_not_built_with(project_path, matches.value_of("toolchains"), dry_run) {

As a bonus, that will avoid calling rustup once for each project.

@jyn514 jyn514 added enhancement New feature or request help wanted We'd appreciate someone creating a PR to address this good first issue Good for newcomers labels Dec 30, 2022
@jyn514 jyn514 closed this as completed in #87 Feb 1, 2023
@marcospb19
Copy link
Collaborator Author

Oops, this needs to be reopened, #87 would fix this but I reverted the commits as requested because the PR was too big, so this issue isn't fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We'd appreciate someone creating a PR to address this
Projects
None yet
2 participants