@@ -4,6 +4,7 @@ use crate::api::ing::{
4
4
fmt_content, get_ing_at_user_tag_text, ing_star_tag_to_text, rm_ing_at_user_tag, IngSendFrom ,
5
5
} ;
6
6
use crate :: api:: news:: get_list:: NewsEntry ;
7
+ use crate :: api:: post:: get_comment_list:: PostCommentEntry ;
7
8
use crate :: api:: post:: get_one:: PostEntry ;
8
9
use crate :: api:: user:: info:: UserInfo ;
9
10
use crate :: infra:: iter:: IteratorExt ;
@@ -201,6 +202,29 @@ pub fn show_post_meta(entry: &Result<PostEntry>) {
201
202
println ! ( "Link https:{}" , entry. url) ;
202
203
}
203
204
205
+ pub fn show_post_comment ( comment_list : & Result < Vec < PostCommentEntry > > , rev : bool ) {
206
+ let comment_list = match comment_list {
207
+ Ok ( entry) => entry,
208
+ Err ( e) => return println_err ( e) ,
209
+ } ;
210
+
211
+ comment_list. iter ( ) . dyn_rev ( rev) . for_each ( |comment| {
212
+ let create_time = {
213
+ let rfc3339 = patch_rfc3339 ( & comment. create_time ) ;
214
+ let dt = DateTime :: parse_from_rfc3339 ( & rfc3339)
215
+ . unwrap_or_else ( |_| panic ! ( "Invalid RFC3339: {}" , rfc3339) ) ;
216
+ dt. format ( "%Y-%m-%d %H:%M" )
217
+ } ;
218
+ let floor_text = format ! ( "{}F" , comment. floor) ;
219
+ println ! (
220
+ "{} {}" ,
221
+ create_time. to_string( ) . dimmed( ) ,
222
+ floor_text. dimmed( )
223
+ ) ;
224
+ println ! ( " {} {}" , comment. user_name. cyan( ) , comment. content) ;
225
+ } )
226
+ }
227
+
204
228
pub fn list_post ( result : & Result < ( Vec < PostEntry > , usize ) > , rev : bool ) {
205
229
let ( entry_list, total_count) = match result {
206
230
Ok ( o) => o,
0 commit comments