style: reformat some code

This commit is contained in:
mokurin000
2025-08-02 09:14:34 +08:00
parent abea7fce11
commit c86626bc75
2 changed files with 18 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ pub struct UserLogoutApi {
pub type_: i64, pub type_: i64,
} }
#[derive(Default, Debug, Clone, PartialEq, Deserialize)] #[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UserLogoutApiResp { pub struct UserLogoutApiResp {
pub return_code: i64, pub return_code: i64,

View File

@@ -28,7 +28,7 @@ use sdgb_api::{
use spdlog::{error, info, warn}; use spdlog::{error, info, warn};
use crate::{ use crate::{
commands::{Cli, RatingFormat}, commands::{Cli, Commands, RatingFormat},
utils::{human_readable_display, json_display, login_action}, utils::{human_readable_display, json_display, login_action},
}; };
@@ -80,7 +80,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
// TODO: refactor via enum_dispatch // TODO: refactor via enum_dispatch
match command { match command {
commands::Commands::MusicDetail { user_id } => { Commands::MusicDetail { user_id } => {
let mut music_detail = Vec::new(); let mut music_detail = Vec::new();
let mut index = None; let mut index = None;
@@ -120,7 +120,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
json_display(music_detail)?; json_display(music_detail)?;
} }
} }
commands::Commands::Rating { user_id, format } => { Commands::Rating { user_id, format } => {
let rating: GetUserRatingApiResp = Sdgb1_50::request( let rating: GetUserRatingApiResp = Sdgb1_50::request(
&client, &client,
APIMethod::GetUserRatingApi, APIMethod::GetUserRatingApi,
@@ -149,7 +149,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
} }
} }
} }
commands::Commands::Logout { user_id, timestamp } => { Commands::Logout { user_id, timestamp } => {
let logout: UserLogoutApiResp = Sdgb1_50::request( let logout: UserLogoutApiResp = Sdgb1_50::request(
&client, &client,
APIMethod::UserLogoutApi, APIMethod::UserLogoutApi,
@@ -161,9 +161,14 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
}, },
) )
.await?; .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( let preview: GetUserPreviewApiResp = Sdgb1_50::request(
&client, &client,
APIMethod::GetUserPreviewApi, APIMethod::GetUserPreviewApi,
@@ -174,7 +179,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
human_readable_display(preview, human_readable)?; human_readable_display(preview, human_readable)?;
} }
commands::Commands::Ping => { Commands::Ping => {
let time = SystemTime::now(); let time = SystemTime::now();
let decoded: PingResp = let decoded: PingResp =
Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?; Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?;
@@ -183,7 +188,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
time.elapsed().unwrap_or_default().as_millis() time.elapsed().unwrap_or_default().as_millis()
); );
} }
commands::Commands::QRLogin { ref qrcode_content } => { Commands::QRLogin { ref qrcode_content } => {
let qrcode = QRCode { qrcode_content }; let qrcode = QRCode { qrcode_content };
let resp = qrcode.login(&client).await; let resp = qrcode.login(&client).await;
@@ -197,7 +202,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
} }
} }
commands::Commands::AuthLite { title_ver, variant } => { Commands::AuthLite { title_ver, variant } => {
let resp = match variant { let resp = match variant {
commands::AuthLiteVariant::SDGB => delivery_raw::<SDGB>(&client, title_ver).await?, commands::AuthLiteVariant::SDGB => delivery_raw::<SDGB>(&client, title_ver).await?,
commands::AuthLiteVariant::SDHJ => delivery_raw::<SDHJ>(&client, title_ver).await?, commands::AuthLiteVariant::SDHJ => delivery_raw::<SDHJ>(&client, title_ver).await?,
@@ -206,7 +211,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
} }
#[cfg(feature = "fetchall")] #[cfg(feature = "fetchall")]
commands::Commands::ListAllUser { concurrency } => { Commands::ListAllUser { concurrency } => {
use futures_util::StreamExt; use futures_util::StreamExt;
use sdgb_api::bincode::borrow_decode_from_slice; use sdgb_api::bincode::borrow_decode_from_slice;
use std::io::{self, BufRead}; use std::io::{self, BufRead};
@@ -291,7 +296,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
let _ = write.commit(); let _ = write.commit();
} }
#[cfg(feature = "fetchall")] #[cfg(feature = "fetchall")]
commands::Commands::ListAllUserDump { .. } => { Commands::ListAllUserDump { .. } => {
use std::{fs::OpenOptions, io::BufWriter}; use std::{fs::OpenOptions, io::BufWriter};
use redb::ReadableTable; use redb::ReadableTable;
@@ -327,7 +332,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
info!("dumped {} user id", user_ids.len()); info!("dumped {} user id", user_ids.len());
} }
commands::Commands::Userdata { user_id } => { Commands::Userdata { user_id } => {
let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>( let action = async |_| match Sdgb1_50::request::<_, GetUserDataApiResp>(
&client, &client,
APIMethod::GetUserDataApi, APIMethod::GetUserDataApi,