mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Add version string CLI parameter, set name to optional parameter, default to 'librespot'
This commit is contained in:
parent
c8e45ab690
commit
4beb3d5e60
1 changed files with 18 additions and 2 deletions
20
src/main.rs
20
src/main.rs
|
@ -71,6 +71,16 @@ fn list_backends() {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_version() {
|
||||
println!(
|
||||
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id})",
|
||||
semver = version::SEMVER,
|
||||
sha = version::SHA_SHORT,
|
||||
build_date = version::BUILD_DATE,
|
||||
build_id = version::BUILD_ID
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Setup {
|
||||
backend: fn(Option<String>) -> Box<dyn Sink>,
|
||||
|
@ -103,7 +113,7 @@ fn setup(args: &[String]) -> Setup {
|
|||
"Path to a directory where system files (credentials, volume) will be cached. Can be different from cache option value",
|
||||
"SYTEMCACHE",
|
||||
).optflag("", "disable-audio-cache", "Disable caching of the audio data.")
|
||||
.reqopt("n", "name", "Device name", "NAME")
|
||||
.optopt("n", "name", "Device name", "NAME")
|
||||
.optopt("", "device-type", "Displayed device type", "DEVICE_TYPE")
|
||||
.optopt(
|
||||
"b",
|
||||
|
@ -119,6 +129,7 @@ fn setup(args: &[String]) -> Setup {
|
|||
)
|
||||
.optflag("", "emit-sink-events", "Run program set by --onevent before sink is opened and after it is closed.")
|
||||
.optflag("v", "verbose", "Enable verbose output")
|
||||
.optflag("V", "version", "Display librespot version string")
|
||||
.optopt("u", "username", "Username to sign in with", "USERNAME")
|
||||
.optopt("p", "password", "Password", "PASSWORD")
|
||||
.optopt("", "proxy", "HTTP proxy to use when connecting", "PROXY")
|
||||
|
@ -220,6 +231,11 @@ fn setup(args: &[String]) -> Setup {
|
|||
}
|
||||
};
|
||||
|
||||
if matches.opt_present("version") {
|
||||
print_version();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let verbose = matches.opt_present("verbose");
|
||||
setup_logging(verbose);
|
||||
|
||||
|
@ -306,7 +322,7 @@ fn setup(args: &[String]) -> Setup {
|
|||
.map(|port| port.parse::<u16>().unwrap())
|
||||
.unwrap_or(0);
|
||||
|
||||
let name = matches.opt_str("name").unwrap();
|
||||
let name = matches.opt_str("name").unwrap_or("Librespot".to_string());
|
||||
|
||||
let credentials = {
|
||||
let cached_credentials = cache.as_ref().and_then(Cache::credentials);
|
||||
|
|
Loading…
Reference in a new issue