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 supported features and audio backend in --version #1312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antomfdez
Copy link

Fixes #1255

Copy link
Member

@eladyn eladyn left a comment

Choose a reason for hiding this comment

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

Thank you and sorry for the long delay! I made some comments, but it looks like a good approach I think.

)
}

pub fn get_enabled_backends() -> Vec<&'static str> {
Copy link
Member

Choose a reason for hiding this comment

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

This should be basically the same as BACKEND_VALUES defined a little below, maybe we can use that instead?

Comment on lines +380 to +390
pub fn get_enabled_features() -> Vec<&'static str> {
let mut features = Vec::new();

#[cfg(feature = "dbus_mpris")]
features.push("MPRIS");

#[cfg(feature = "dbus_keyring")]
features.push("keyring");

features
}
Copy link
Member

Choose a reason for hiding this comment

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

I think I would also prefer the

&[
#[cfg(feature = "dbus_mpris")]
"MPRIS",
// ...
]

style here, but not that important.

#[structopt(
about = "A Spotify daemon",
about = &**ABOUT_INFO, // Use double dereference to get `&str`
Copy link
Member

Choose a reason for hiding this comment

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

Instead of replacing about, I think there is also version, which is probably more what we want? Or was there a specific reason why you went for about?

Comment on lines +420 to +431
impl Default for CliConfig {
fn default() -> Self {
CliConfig {
config_path: None,
no_daemon: false,
verbose: false,
pid: None,
shared_config: SharedConfigValues::default(),
}
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this exactly do, what #[derive(Default)] would do as well?

Comment on lines +102 to +106
// Handle --version explicitly
if std::env::args().any(|arg| arg == "--version") {
println!("{}", &**ABOUT_INFO);
return Ok(());
}
Copy link
Member

Choose a reason for hiding this comment

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

If we specify version = &**ABOUT_INFO instead, this would probably also not be necessary.

let backends = get_enabled_backends();

let features_str = if features.is_empty() {
"No features enabled".to_string()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"No features enabled".to_string()
"none".to_string()

would probably also be sufficient.

@@ -36,6 +36,7 @@ librespot-connect = { version = "0.4" }
toml = "0.7"
color-eyre = "0.6"
directories = "5.0.1"
once_cell = "1.20.2"
Copy link
Member

Choose a reason for hiding this comment

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

In theory, since recently, the standard library also has support for those Lazy cells e.g. with std::cell::LazyCell. But to make use of that, we would need a MSRV bump, so this would also be fine for now! Whatever suits you best. :)

@antomfdez
Copy link
Author

Thank you and sorry for the long delay! I made some comments, but it looks like a good approach I think.

I'm gonna take a look the next few days to see if I can fix it

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

Successfully merging this pull request may close these issues.

Show supported features in --version
2 participants