-
Notifications
You must be signed in to change notification settings - Fork 459
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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> { |
There was a problem hiding this comment.
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?
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 | ||
} |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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
?
impl Default for CliConfig { | ||
fn default() -> Self { | ||
CliConfig { | ||
config_path: None, | ||
no_daemon: false, | ||
verbose: false, | ||
pid: None, | ||
shared_config: SharedConfigValues::default(), | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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?
// Handle --version explicitly | ||
if std::env::args().any(|arg| arg == "--version") { | ||
println!("{}", &**ABOUT_INFO); | ||
return Ok(()); | ||
} |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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" |
There was a problem hiding this comment.
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. :)
I'm gonna take a look the next few days to see if I can fix it |
Fixes #1255