Skip to content

Commit

Permalink
feat: show ing source
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 13, 2023
1 parent 88f0a6f commit 2226f9d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ serde = { version = "1.0.188", features = ["derive"] }
serde_qs = "0.12.0"
serde_json = "1.0.106"
serde_with = "3.3.0"
serde_repr = "0.1.16"

home = "0.5.5"
chrono = "0.4.30"
Expand Down
4 changes: 2 additions & 2 deletions src/api/ing/get_list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::api::ing::{Ing, IngType};
use crate::api::ing::{Ing, IngSendFrom, IngType};
use crate::infra::http::{body_or_err, RequestBuilderExt};
use crate::infra::json;
use crate::infra::result::IntoResult;
Expand Down Expand Up @@ -31,7 +31,7 @@ pub struct IngEntry {
#[serde(rename = "UserGuid")]
pub user_guid: String,
#[serde(rename = "SendFrom")]
pub send_from: usize,
pub send_from: IngSendFrom,
#[serde(rename = "Icons")]
pub icons: String,
}
Expand Down
4 changes: 3 additions & 1 deletion src/api/ing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::infra::result::IntoResult;
use anyhow::bail;
use lazy_static::lazy_static;
use regex::Regex;
use serde_repr::{Deserialize_repr, Serialize_repr};

pub mod get_comment_list;
pub mod get_list;
Expand All @@ -31,7 +32,8 @@ pub enum IngType {
Mention = 14,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum IngSendFrom {
None = 0,
Ms = 1,
Expand Down
12 changes: 11 additions & 1 deletion src/display/colorful.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::ing::get_list::{IngCommentEntry, IngEntry};
use crate::api::ing::{
fmt_content, get_ing_at_user_tag_text, ing_star_tag_to_text, rm_ing_at_user_tag,
fmt_content, get_ing_at_user_tag_text, ing_star_tag_to_text, rm_ing_at_user_tag, IngSendFrom,
};
use crate::api::news::get_list::NewsEntry;
use crate::api::post::get_one::PostEntry;
Expand Down Expand Up @@ -67,6 +67,16 @@ pub fn list_ing(ing_list: &Result<Vec<(IngEntry, Vec<IngCommentEntry>)>>, rev: b
};

print!("{}", create_time.dimmed());
let send_from_mark = match ing.send_from {
IngSendFrom::Cli => Some("CLI"),
IngSendFrom::CellPhone => Some("Mobile"),
IngSendFrom::VsCode => Some("VSCode"),
IngSendFrom::Web => Some("Web"),
_ => None,
};
if let Some(mark) = send_from_mark {
print!(" {}", mark.dimmed());
}
if ing.is_lucky {
let star_text = ing_star_tag_to_text(&ing.icons);
print!(" {}⭐", star_text.yellow());
Expand Down
13 changes: 12 additions & 1 deletion src/display/normal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::ing::get_list::{IngCommentEntry, IngEntry};
use crate::api::ing::{
fmt_content, get_ing_at_user_tag_text, ing_star_tag_to_text, rm_ing_at_user_tag,
fmt_content, get_ing_at_user_tag_text, ing_star_tag_to_text, rm_ing_at_user_tag, IngSendFrom,
};
use crate::api::news::get_list::NewsEntry;
use crate::api::post::get_one::PostEntry;
Expand All @@ -9,6 +9,7 @@ use crate::infra::iter::IteratorExt;
use crate::infra::time::patch_rfc3339;
use anyhow::Result;
use chrono::DateTime;
use colored::Colorize;
use std::fmt::Display;
use std::ops::Not;
use std::path::PathBuf;
Expand Down Expand Up @@ -66,6 +67,16 @@ pub fn list_ing(ing_list: &Result<Vec<(IngEntry, Vec<IngCommentEntry>)>>, rev: b
};

print!("{}", create_time);
let send_from_mark = match ing.send_from {
IngSendFrom::Cli => Some("CLI"),
IngSendFrom::CellPhone => Some("Mobile"),
IngSendFrom::VsCode => Some("VSCode"),
IngSendFrom::Web => Some("Web"),
_ => None,
};
if let Some(mark) = send_from_mark {
print!(" {}", mark.dimmed());
}
if ing.is_lucky {
let star_text = ing_star_tag_to_text(&ing.icons);
print!(" {}⭐", star_text);
Expand Down

0 comments on commit 2226f9d

Please sign in to comment.