|
1 | 1 | use chrono::{Datelike, Timelike}; |
2 | 2 | use colored::Colorize; |
3 | 3 |
|
4 | | -pub fn aboutme(){ |
| 4 | +#[tracing::instrument] |
| 5 | +pub fn aboutme() { |
5 | 6 | let token = super::expect_token(); |
6 | 7 | match crate::entities::user::fetch_user(token.clone()) { |
7 | 8 | Ok(user) => { |
8 | 9 | println!("ID: {}", user.user_id.bright_black()); |
9 | 10 | println!("Plan: {}", color_plan(user.plan)); |
10 | 11 | let end_date = user.plan_data_end; |
11 | | - println!("Your plan ends at: {}/{}/{} {}:{}", end_date.day(), end_date.month(), end_date.year(), end_date.hour(), end_date.minute()); |
12 | | - println!(" Which means you have {} days left!", user.last_data_left.days.to_string().green().bold()); |
| 12 | + println!( |
| 13 | + "Your plan ends at: {}/{}/{} {}:{}", |
| 14 | + end_date.day(), |
| 15 | + end_date.month(), |
| 16 | + end_date.year(), |
| 17 | + end_date.hour(), |
| 18 | + end_date.minute() |
| 19 | + ); |
| 20 | + println!( |
| 21 | + " Which means you have {} days left!", |
| 22 | + user.last_data_left.days.to_string().green().bold() |
| 23 | + ); |
13 | 24 | println!("Memory:"); |
14 | | - println!(" Total: {}{}", user.total_ram_mb.to_string().green().bold(), "MB".green().bold()); |
15 | | - println!(" Used: {}{}", user.ram_used_mb.to_string().green().bold(), "MB".green().bold()); |
16 | | - println!(" Available: {}{}", (user.total_ram_mb - user.ram_used_mb).to_string().green().bold(), "MB".green().bold()); |
| 25 | + println!( |
| 26 | + " Total: {}{}", |
| 27 | + user.total_ram_mb.to_string().green().bold(), |
| 28 | + "MB".green().bold() |
| 29 | + ); |
| 30 | + println!( |
| 31 | + " Used: {}{}", |
| 32 | + user.ram_used_mb.to_string().green().bold(), |
| 33 | + "MB".green().bold() |
| 34 | + ); |
| 35 | + println!( |
| 36 | + " Available: {}{}", |
| 37 | + (user.total_ram_mb - user.ram_used_mb) |
| 38 | + .to_string() |
| 39 | + .green() |
| 40 | + .bold(), |
| 41 | + "MB".green().bold() |
| 42 | + ); |
17 | 43 | println!("Locale: {}", user.locale.blue()); |
18 | 44 | } |
19 | | - Err(err) => super::err(&err.to_string()) |
20 | | - } |
| 45 | + Err(err) => super::err(&err.to_string()), |
| 46 | + } |
21 | 47 | } |
| 48 | +#[tracing::instrument] |
22 | 49 | fn color_plan(plan: String) -> String { |
23 | | - match plan.as_str() { |
24 | | - "Free" => { |
25 | | - plan.bright_black().to_string() |
26 | | - } |
27 | | - "Carbon" => { |
28 | | - plan.bright_black().bold().to_string() |
29 | | - } |
30 | | - "Gold" => { |
31 | | - plan.yellow().bold().to_string() |
32 | | - } |
33 | | - "Platinum" => { |
34 | | - plan.blue().bold().to_string() |
35 | | - } |
36 | | - "Diamond" => { |
37 | | - plan.cyan().bold().to_string() |
38 | | - } |
39 | | - "Ruby" => { |
40 | | - plan.red().bold().to_string() |
41 | | - } |
42 | | - "Sapphire" => { |
43 | | - plan.bright_red().bold().to_string() |
44 | | - } |
45 | | - "Krypton" => { |
46 | | - plan.bright_green().bold().to_string() |
47 | | - } |
48 | | - "Special" => { |
49 | | - plan.bright_cyan().bold().to_string() |
50 | | - } |
51 | | - _ => unreachable!() |
52 | | - } |
| 50 | + match plan.as_str() { |
| 51 | + "Free" => plan.bright_black().to_string(), |
| 52 | + "Carbon" => plan.bright_black().bold().to_string(), |
| 53 | + "Gold" => plan.yellow().bold().to_string(), |
| 54 | + "Platinum" => plan.blue().bold().to_string(), |
| 55 | + "Diamond" => plan.cyan().bold().to_string(), |
| 56 | + "Ruby" => plan.red().bold().to_string(), |
| 57 | + "Sapphire" => plan.bright_red().bold().to_string(), |
| 58 | + "Krypton" => plan.bright_green().bold().to_string(), |
| 59 | + "Special" => plan.bright_cyan().bold().to_string(), |
| 60 | + _ => unreachable!(), |
| 61 | + } |
53 | 62 | } |
0 commit comments