removed feature skeleton

This commit is contained in:
Nickiel12 2023-01-06 20:09:39 -08:00
parent d4b35c4e9b
commit bf2fc2181f

View file

@ -50,7 +50,6 @@ struct CliArgs {
value_parser(["title", "artist", "album"]), value_parser(["title", "artist", "album"]),
)] )]
field: String, field: String,
// Add flag for "search filepaths too" for music lacking metadata // Add flag for "search filepaths too" for music lacking metadata
} }
@ -67,11 +66,14 @@ fn main() {
SousaCommands::Play => serde_json::to_string(&UIRequest::Play).unwrap(), SousaCommands::Play => serde_json::to_string(&UIRequest::Play).unwrap(),
SousaCommands::Pause => serde_json::to_string(&UIRequest::Pause).unwrap(), SousaCommands::Pause => serde_json::to_string(&UIRequest::Pause).unwrap(),
SousaCommands::Search => { SousaCommands::Search => {
let request = UIRequest::Search(parse_to_partialtag(cli.field, cli.search_arg.unwrap()).unwrap()); let request =
UIRequest::Search(parse_to_partialtag(cli.field, cli.search_arg.unwrap()).unwrap());
serde_json::to_string(&request).unwrap() serde_json::to_string(&request).unwrap()
} }
SousaCommands::SwitchTo => { SousaCommands::SwitchTo => {
let request = UIRequest::SwitchTo(parse_to_partialtag(cli.field, cli.search_arg.unwrap()).unwrap()); let request = UIRequest::SwitchTo(
parse_to_partialtag(cli.field, cli.search_arg.unwrap()).unwrap(),
);
serde_json::to_string(&request).unwrap() serde_json::to_string(&request).unwrap()
} }
SousaCommands::StatusUpdate => { SousaCommands::StatusUpdate => {
@ -85,18 +87,14 @@ fn main() {
.expect("Error sending message"); .expect("Error sending message");
let server_message = socket.read_message().expect("Error reading message"); let server_message = socket.read_message().expect("Error reading message");
let server_response: message_types::ServerResponse = match serde_json::from_str(server_message.clone().into_text().unwrap().as_str()) { if server_message.is_empty() {
Ok(sr) => sr, socket.close(None).unwrap();
Err(error) => { panic!("The server returned nothing");
println!("\n\nThere was an error decoding the message from the server"); }
println!("\nThe Message was: {}", server_message);
println!("\n\n {}", error); let server_response: message_types::ServerResponse =
socket.close(None).unwrap(); serde_json::from_str(server_message.clone().into_text().unwrap().as_str()).unwrap();
return ();
}
};
println!("{}", server_response.message.clone());
if server_response if server_response
.message .message
.starts_with("Multiple results found") .starts_with("Multiple results found")
@ -134,7 +132,7 @@ fn main() {
} }
/// Print the table of partial matches to the switch-to /// Print the table of partial matches to the switch-to
/// ///
/// Takes the Server Response object, and creates a table out of the /// Takes the Server Response object, and creates a table out of the
/// results for the user to select an index of. /// results for the user to select an index of.
fn print_switchto_table(msg: ServerResponse) { fn print_switchto_table(msg: ServerResponse) {
@ -170,10 +168,10 @@ fn print_switchto_table(msg: ServerResponse) {
} }
/// Creates a PartialTag from the `--field` and `SEARCH_ARG` /// Creates a PartialTag from the `--field` and `SEARCH_ARG`
/// ///
/// Takes the field as a string, and the SEARCH_ARG as a string, and /// Takes the field as a string, and the SEARCH_ARG as a string, and
/// returns a partialtag with the value in the field specified by field. /// returns a partialtag with the value in the field specified by field.
/// ///
/// ``` /// ```
/// let partial_tag = parse_to_partialtag("title".to_string(), "Rocker Song".to_string()).unwrap(); /// let partial_tag = parse_to_partialtag("title".to_string(), "Rocker Song".to_string()).unwrap();
/// assert_eq!(partial_tag.title, Some("Rocker Song".to_string())) /// assert_eq!(partial_tag.title, Some("Rocker Song".to_string()))
@ -197,8 +195,7 @@ fn parse_to_partialtag(field: String, value: String) -> Result<PartialTag, Strin
} }
impl ServerResponse { impl ServerResponse {
/// Prints
/// Prints
fn pretty_print(self: &Self) -> () { fn pretty_print(self: &Self) -> () {
let mut table = Table::new(vec![ let mut table = Table::new(vec![
"Title".to_string(), "Title".to_string(),
@ -217,7 +214,6 @@ impl ServerResponse {
} }
} }
#[test] #[test]
fn test_partialtag() { fn test_partialtag() {
let partial_tag = parse_to_partialtag("title".to_string(), "Rocker Song".to_string()).unwrap(); let partial_tag = parse_to_partialtag("title".to_string(), "Rocker Song".to_string()).unwrap();