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

NEXT-37318 - copy default profiles from executable #4

Merged
merged 4 commits into from
Jul 29, 2024

Conversation

LarsKemper
Copy link
Member

@LarsKemper LarsKemper commented Jul 22, 2024

@MalteJanz, is there a way to better organize environment constants? It feels a bit awkward to hardcode things like this or this.

You might need to update your settings.json in VS Code to clear an analyzer error found here: link.

{
   "rust-analyzer.server.path": "rust-analyzer"
}

@LarsKemper LarsKemper changed the title NEXT-37318 - copy default profiles from executable NEXT-37318 - copy default profiles from executable (WIP) Jul 22, 2024
@LarsKemper LarsKemper force-pushed the next-37318/copy-default-profiles-from-executable branch from 4deac8c to a5a1bde Compare July 22, 2024 13:50
@LarsKemper LarsKemper requested a review from MalteJanz July 22, 2024 13:51
@LarsKemper LarsKemper added the enhancement New feature or request label Jul 22, 2024
@LarsKemper LarsKemper changed the title NEXT-37318 - copy default profiles from executable (WIP) NEXT-37318 - copy default profiles from executable Jul 22, 2024
@LarsKemper LarsKemper self-assigned this Jul 22, 2024
Copy link
Contributor

@MalteJanz MalteJanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the implementation of this new command, great work 👍 .

But I'm not really sure if we want this build script, we can also talk about it, just reach out 🙂

Cargo.toml Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/resources/profiles/manufacturer.yaml Outdated Show resolved Hide resolved
@MalteJanz
Copy link
Contributor

Regarding you question: I don't know of any constants for the build script, just this documentation:
https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

So I think you would need to hard code them...

@LarsKemper LarsKemper force-pushed the next-37318/copy-default-profiles-from-executable branch from a5a1bde to 4abd90c Compare July 29, 2024 12:36
@LarsKemper LarsKemper requested a review from MalteJanz July 29, 2024 12:39
@LarsKemper LarsKemper force-pushed the next-37318/copy-default-profiles-from-executable branch from 4abd90c to 3352229 Compare July 29, 2024 12:39
@@ -15,6 +16,25 @@ mod cli;
mod config_file;
mod data;

const PROFILES: &[(&str, &str)] = &[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to try to write a unit test that ensures that all files in ./profiles folder are actually defined in this array?
https://doc.rust-lang.org/book/ch11-01-writing-tests.html

You could also extend it to parse these profiles and see if that produces errors.

If you don't, that's also fine and I try to cover it together with my "test coverage" ticket 🙂

@LarsKemper LarsKemper merged commit 64b89d3 into main Jul 29, 2024
3 checks passed
@LarsKemper LarsKemper deleted the next-37318/copy-default-profiles-from-executable branch July 29, 2024 12:44
Comment on lines +127 to +138
let mut dir_path = PathBuf::from("./profiles");

if path.is_some() {
let path = path.unwrap();

if !path.is_dir() && !force {
eprintln!("Path is not a directory: {:?}", path);
return;
}

dir_path = path;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little more idomatic rust 🤓

Suggested change
let mut dir_path = PathBuf::from("./profiles");
if path.is_some() {
let path = path.unwrap();
if !path.is_dir() && !force {
eprintln!("Path is not a directory: {:?}", path);
return;
}
dir_path = path;
}
let Some(dir_path) = path else {
PathBuf::from("./profiles")
};
if !dir_path.is_dir() && !force {
eprintln!("Path is not a directory: {:?}", path);
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants