Handle space-delimited parameter
This commit is contained in:
parent
2d00d596a0
commit
394121a80c
1 changed files with 134 additions and 131 deletions
35
src/main.rs
35
src/main.rs
|
|
@ -1,6 +1,14 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
|
mod converter;
|
||||||
|
mod downloader;
|
||||||
|
mod error;
|
||||||
|
mod server;
|
||||||
|
mod settings;
|
||||||
|
mod spotify;
|
||||||
|
mod tag;
|
||||||
|
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use downloader::{DownloadState, Downloader};
|
use downloader::{DownloadState, Downloader};
|
||||||
|
|
@ -11,13 +19,6 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod converter;
|
|
||||||
mod downloader;
|
|
||||||
mod error;
|
|
||||||
mod settings;
|
|
||||||
mod spotify;
|
|
||||||
mod tag;
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
@ -71,7 +72,14 @@ async fn start() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
if args.len() > 1 {
|
if args.len() <= 1 {
|
||||||
|
println!(
|
||||||
|
"Usage:\n{} (track_url | album_url | playlist_url | artist_url )",
|
||||||
|
args[0]
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let spotify = match Spotify::new(
|
let spotify = match Spotify::new(
|
||||||
&settings.username,
|
&settings.username,
|
||||||
&settings.password,
|
&settings.password,
|
||||||
|
|
@ -94,9 +102,10 @@ async fn start() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let downloader = Downloader::new(settings.downloader, spotify);
|
let input = args[1..].join(" ");
|
||||||
|
|
||||||
match downloader.handle_input(&args[1]).await {
|
let downloader = Downloader::new(settings.downloader, spotify);
|
||||||
|
match downloader.handle_input(&input).await {
|
||||||
Ok(search_results) => {
|
Ok(search_results) => {
|
||||||
if let Some(search_results) = search_results {
|
if let Some(search_results) = search_results {
|
||||||
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
||||||
|
|
@ -194,10 +203,4 @@ async fn start() {
|
||||||
error!("{} {}", "Handling input failed:".red(), e)
|
error!("{} {}", "Handling input failed:".red(), e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
println!(
|
|
||||||
"Usage:\n{} (track_url | album_url | playlist_url | artist_url )",
|
|
||||||
args[0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue