From 33ca4502e44fa1d1e18e29b77cab66e1db02ac7a Mon Sep 17 00:00:00 2001 From: MCorange Date: Thu, 19 Sep 2024 19:12:07 +0300 Subject: [PATCH] Fixed warnings from cargo --- scripts/build-release.sh | 8 +-- src/commands/gui/mod.rs | 7 +-- src/commands/gui/nav_bar.rs | 3 - src/commands/gui/song_edit_window.rs | 7 +-- src/manifest/mod.rs | 4 +- src/manifest/playlist.rs | 6 +- src/prompt.rs | 85 ++++++++++++++-------------- src/util.rs | 12 +--- 8 files changed, 54 insertions(+), 78 deletions(-) diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 27a3461..dcb4630 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -11,8 +11,8 @@ cargo build --release --target x86_64-pc-windows-gnu cargo build --release --target x86_64-unknown-linux-gnu cargo build --release --target aarch64-unknown-linux-gnu -cp ./target/x86_64-pc-windows-gnu/release/mcmg.exe ./target/mcmg_win32.exe -cp ./target/x86_64-unknown-linux-gnu/release/mcmg ./target/mcmg_linux_x86_64 -cp ./target/aarch64-unknown-linux-gnu/release/mcmg ./target/mcmg_linux_aarch64 -cp ./scripts/setup-template.sh "./target/mcmg-setup-$1.sh" +strip --strip-unneeded ./target/x86_64-pc-windows-gnu/release/mcmg.exe -o ./target/mcmg_win32.exe +strip --strip-unneeded ./target/x86_64-unknown-linux-gnu/release/mcmg -o ./target/mcmg_linux_x86_64 +aarch64-linux-gnu-strip --strip-unneeded ./target/aarch64-unknown-linux-gnu/release/mcmg -o ./target/mcmg_linux_aarch64 +cp ./scripts/setup-template.sh "./target/mcmg-setup-$1.sh" cp ./scripts/setup-template.ps1 "./target/mcmg-setup-$1.ps1" diff --git a/src/commands/gui/mod.rs b/src/commands/gui/mod.rs index bdb2e86..2c2dee7 100644 --- a/src/commands/gui/mod.rs +++ b/src/commands/gui/mod.rs @@ -1,14 +1,11 @@ mod nav_bar; mod song_edit_window; - -use std::collections::HashSet; - -use egui::{Button, Color32, Label, RichText, Sense}; +use egui::{Color32, RichText}; use egui_extras::{Column, TableBuilder}; use song_edit_window::{GuiError, GuiImportPlaylist, GuiNewSong}; -use crate::{config::{Config, ConfigWrapper}, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}}; +use crate::{config::ConfigWrapper, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}}; use self::song_edit_window::GuiSongEditor; diff --git a/src/commands/gui/nav_bar.rs b/src/commands/gui/nav_bar.rs index ee65176..822a32a 100644 --- a/src/commands/gui/nav_bar.rs +++ b/src/commands/gui/nav_bar.rs @@ -1,8 +1,5 @@ -use egui::Hyperlink; - use super::Gui; - impl Gui { pub fn draw_nav(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) { diff --git a/src/commands/gui/song_edit_window.rs b/src/commands/gui/song_edit_window.rs index c53e9af..1dac2fd 100644 --- a/src/commands/gui/song_edit_window.rs +++ b/src/commands/gui/song_edit_window.rs @@ -1,10 +1,7 @@ - -use std::sync::Arc; - -use egui::{text::{LayoutJob, TextWrapping}, Color32, Label, RichText, Style, TextBuffer, TextFormat, TextStyle}; +use egui::{Color32, Label, RichText}; -use crate::manifest::{playlist::Playlist, song::{Song, SongType}}; +use crate::manifest::song::{Song, SongType}; use super::Gui; diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 07e922f..dbe0d99 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize}; const DEFAULT_MANIFEST: &'static str = include_str!("../../manifest.default.json"); -pub type SongName = String; -pub type Genre = HashMap; #[allow(non_camel_case_types)] #[derive(Debug, Serialize, Deserialize, Clone, Default)] @@ -43,7 +41,7 @@ impl Manifest { pub fn get_format(&self) -> &Format { &self.format } - pub fn add_song(&mut self, playlist_name: &String, name: SongName, song: Song) -> Option { + pub fn add_song(&mut self, playlist_name: &String, name: String, song: Song) -> Option { self.get_playlist_mut(playlist_name)?.add_song(name, song) } pub fn get_song(&self, playlist_name: &String, name: &String) -> Option<&Song> { diff --git a/src/manifest/playlist.rs b/src/manifest/playlist.rs index 1dc1153..fc21d62 100644 --- a/src/manifest/playlist.rs +++ b/src/manifest/playlist.rs @@ -13,9 +13,6 @@ pub struct Playlist { impl Playlist { - pub fn new() -> Self { - Self { ..Default::default() } - } pub fn add_song(&mut self, name: String, song: Song) -> Option { self.songs.insert(name, song) @@ -32,7 +29,8 @@ impl Playlist { pub fn get_songs(&self) -> &HashMap { &self.songs } - + + #[allow(dead_code)] pub fn get_songs_mut(&mut self) -> &mut HashMap { &mut self.songs } diff --git a/src/prompt.rs b/src/prompt.rs index b38f624..de9d891 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -1,22 +1,21 @@ use std::{collections::HashMap, io::Write}; - -pub(crate) fn simple_prompt(p: &str) -> String { - - print!("{c}prompt{r}: {p} > ", - c=anstyle::AnsiColor::Cyan.render_fg(), - r=anstyle::Reset.render() - ); - - // I dont care if it fails - let _ = std::io::stdout().flush(); - - let mut buf = String::new(); - let _ = std::io::stdin().read_line(&mut buf); - - buf.trim().to_string() -} +//pub(crate) fn simple_prompt(p: &str) -> String { +// +// print!("{c}prompt{r}: {p} > ", +// c=anstyle::AnsiColor::Cyan.render_fg(), +// r=anstyle::Reset.render() +// ); +// +// // I dont care if it fails +// let _ = std::io::stdout().flush(); +// +// let mut buf = String::new(); +// let _ = std::io::stdin().read_line(&mut buf); +// +// buf.trim().to_string() +//} #[allow(dead_code)] pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize { @@ -47,33 +46,33 @@ pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize { } } -pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String { - println!("{c}prompt{r}: {p} (select with number or input text)", - c=anstyle::AnsiColor::Cyan.render_fg(), - r=anstyle::Reset.render() - ); - - for (i, op) in options.iter().enumerate() { - println!(" - {}: {}", i, op); - } - - print!("> "); - // I dont care if it fails - let _ = std::io::stdout().flush(); - - let mut buf = String::new(); - let _ = std::io::stdin().read_line(&mut buf); - - if let Ok(num) = buf.trim().parse::() { - if let Some(g) = options.get(num) { - return g.clone(); - } else { - return prompt_with_list_or_str(p, options); - } - } else { - return buf.trim().to_string(); - } -} +// pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String { +// println!("{c}prompt{r}: {p} (select with number or input text)", +// c=anstyle::AnsiColor::Cyan.render_fg(), +// r=anstyle::Reset.render() +// ); +// +// for (i, op) in options.iter().enumerate() { +// println!(" - {}: {}", i, op); +// } +// +// print!("> "); +// // I dont care if it fails +// let _ = std::io::stdout().flush(); +// +// let mut buf = String::new(); +// let _ = std::io::stdin().read_line(&mut buf); +// +// if let Ok(num) = buf.trim().parse::() { +// if let Some(g) = options.get(num) { +// return g.clone(); +// } else { +// return prompt_with_list_or_str(p, options); +// } +// } else { +// return buf.trim().to_string(); +// } +// } #[allow(dead_code)] diff --git a/src/util.rs b/src/util.rs index 817f8c0..40c246b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -52,21 +52,11 @@ pub(crate) fn isatty() -> bool { } } - +#[allow(dead_code)] pub fn as_any_mut(val: &mut T) -> &mut dyn Any { val as &mut dyn Any } -// pub async fn dl_to_file(url: &str, p: PathBuf) -> anyhow::Result<()> { -// log::info!("Downloading {} -> {:?}", url, p); -// let ytdlp_req = reqwest::get(url).await?.bytes().await?; -// log::debug!("Downloading {:?} finished, writing to file", p); -// let mut fd = std::fs::File::create(&p)?; -// fd.write(&ytdlp_req)?; -// log::debug!("Finished writing {:?}", p); -// Ok(()) -// } - pub fn get_song_path/*>*/(/*basepath: Option

,*/ pname: &String, sname: &String, format: &Format) -> PathBuf { // let mut path: PathBuf; /*if let Some(bp) = basepath {