diff --git a/sdgb-api/src/title/model/user_logout_api/mod.rs b/sdgb-api/src/title/model/user_logout_api/mod.rs index 75ad3ed..eab58b6 100644 --- a/sdgb-api/src/title/model/user_logout_api/mod.rs +++ b/sdgb-api/src/title/model/user_logout_api/mod.rs @@ -18,7 +18,7 @@ pub struct UserLogoutApi { pub type_: i64, } -#[derive(Default, Debug, Clone, PartialEq, Deserialize)] +#[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct UserLogoutApiResp { pub return_code: i64, diff --git a/sdgb-cli/src/main.rs b/sdgb-cli/src/main.rs index bbebaea..0397ab7 100644 --- a/sdgb-cli/src/main.rs +++ b/sdgb-cli/src/main.rs @@ -28,7 +28,7 @@ use sdgb_api::{ use spdlog::{error, info, warn}; use crate::{ - commands::{Cli, RatingFormat}, + commands::{Cli, Commands, RatingFormat}, utils::{human_readable_display, json_display, login_action}, }; @@ -80,7 +80,7 @@ async fn main() -> Result<(), Box> { // TODO: refactor via enum_dispatch match command { - commands::Commands::MusicDetail { user_id } => { + Commands::MusicDetail { user_id } => { let mut music_detail = Vec::new(); let mut index = None; @@ -120,7 +120,7 @@ async fn main() -> Result<(), Box> { json_display(music_detail)?; } } - commands::Commands::Rating { user_id, format } => { + Commands::Rating { user_id, format } => { let rating: GetUserRatingApiResp = Sdgb1_50::request( &client, APIMethod::GetUserRatingApi, @@ -149,7 +149,7 @@ async fn main() -> Result<(), Box> { } } } - commands::Commands::Logout { user_id, timestamp } => { + Commands::Logout { user_id, timestamp } => { let logout: UserLogoutApiResp = Sdgb1_50::request( &client, APIMethod::UserLogoutApi, @@ -161,9 +161,14 @@ async fn main() -> Result<(), Box> { }, ) .await?; - println!("{logout:?}"); + + if human_readable { + println!("啥都木有"); + } else { + json_display(logout)?; + } } - commands::Commands::Preview { user_id } => { + Commands::Preview { user_id } => { let preview: GetUserPreviewApiResp = Sdgb1_50::request( &client, APIMethod::GetUserPreviewApi, @@ -174,7 +179,7 @@ async fn main() -> Result<(), Box> { human_readable_display(preview, human_readable)?; } - commands::Commands::Ping => { + Commands::Ping => { let time = SystemTime::now(); let decoded: PingResp = Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?; @@ -183,7 +188,7 @@ async fn main() -> Result<(), Box> { time.elapsed().unwrap_or_default().as_millis() ); } - commands::Commands::QRLogin { ref qrcode_content } => { + Commands::QRLogin { ref qrcode_content } => { let qrcode = QRCode { qrcode_content }; let resp = qrcode.login(&client).await; @@ -197,7 +202,7 @@ async fn main() -> Result<(), Box> { } } - commands::Commands::AuthLite { title_ver, variant } => { + Commands::AuthLite { title_ver, variant } => { let resp = match variant { commands::AuthLiteVariant::SDGB => delivery_raw::(&client, title_ver).await?, commands::AuthLiteVariant::SDHJ => delivery_raw::(&client, title_ver).await?, @@ -206,7 +211,7 @@ async fn main() -> Result<(), Box> { } #[cfg(feature = "fetchall")] - commands::Commands::ListAllUser { concurrency } => { + Commands::ListAllUser { concurrency } => { use futures_util::StreamExt; use sdgb_api::bincode::borrow_decode_from_slice; use std::io::{self, BufRead}; @@ -291,7 +296,7 @@ async fn main() -> Result<(), Box> { let _ = write.commit(); } #[cfg(feature = "fetchall")] - commands::Commands::ListAllUserDump { .. } => { + Commands::ListAllUserDump { .. } => { use std::{fs::OpenOptions, io::BufWriter}; use redb::ReadableTable; @@ -327,7 +332,7 @@ async fn main() -> Result<(), Box> { info!("dumped {} user id", user_ids.len()); } - commands::Commands::Userdata { user_id } => { + Commands::Userdata { user_id } => { let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>( &client, APIMethod::GetUserDataApi,