mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 10:19:27 +02:00
parent
d0a84d7915
commit
7ba3d766c0
5 changed files with 42 additions and 22 deletions
17
src/main.rs
17
src/main.rs
|
@ -1,13 +1,10 @@
|
|||
extern crate getopts;
|
||||
extern crate librespot;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate ctrlc;
|
||||
|
||||
use std::io::{stderr, Write};
|
||||
use std::process::exit;
|
||||
use std::thread;
|
||||
use std::env;
|
||||
|
||||
use librespot::spirc::SpircManager;
|
||||
use librespot::main_helper;
|
||||
|
@ -18,27 +15,23 @@ fn usage(program: &str, opts: &getopts::Options) -> String {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
if env::var("RUST_LOG").is_err() {
|
||||
env::set_var("RUST_LOG", "mdns=info,librespot=trace")
|
||||
}
|
||||
env_logger::init().unwrap();
|
||||
|
||||
let mut opts = getopts::Options::new();
|
||||
main_helper::add_session_arguments(&mut opts);
|
||||
main_helper::add_authentication_arguments(&mut opts);
|
||||
main_helper::add_player_arguments(&mut opts);
|
||||
main_helper::add_program_arguments(&mut opts);
|
||||
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let matches = match opts.parse(&args[1..]) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
error!("Error: {}\n{}", f.to_string(), usage(&args[0], &opts));
|
||||
exit(1)
|
||||
writeln!(stderr(), "error: {}\n{}", f.to_string(), usage(&args[0], &opts)).unwrap();
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
main_helper::setup_logging(&matches);
|
||||
|
||||
let session = main_helper::create_session(&matches);
|
||||
let credentials = main_helper::get_credentials(&session, &matches);
|
||||
session.login(credentials).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue