Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 3b96af3

Browse files
committed
fix: a lot of stuff
1 parent 7bcdafc commit 3b96af3

File tree

23 files changed

+302
-223
lines changed

23 files changed

+302
-223
lines changed

Cargo.lock

Lines changed: 79 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ version = "0.3.2-alpha"
77
edition = "2021"
88
description = "Blazingly fast Discloud CLI"
99
license = "Apache-2.0"
10-
license-file = "LICENSE"
1110
categories = ["command-line-utilities"]
1211
keywords = ["discloud", "cli", "bot", "fast", "discord"]
1312
readme = "README.md"
@@ -22,5 +21,7 @@ reqwest = { version = "0.11.12", features = ["blocking", "json", "multipart", "r
2221
sentry = {version = "0.29.1", default-features = false, features = ["rustls", "reqwest"]}
2322
serde = { version = "1.0.150", features = ["derive"] }
2423
spinners = "4.1.0"
24+
tracing = "0.1.36"
25+
tracing-subscriber = { version = "0.3.15" }
2526
walkdir = "2.3.2"
26-
zip = "0.6.3"
27+
zip = "0.6.3"

src/auth.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use crate::api_url;
22

3+
#[tracing::instrument]
34
pub fn login(token: String) -> std::io::Result<()> {
45
let token_file = crate::config_dir::get_path(".discloud_token").unwrap();
56
std::fs::write(token_file, token)?;
67
Ok(())
78
}
9+
#[tracing::instrument]
810
pub fn get_token() -> std::io::Result<String> {
911
let token_file = crate::config_dir::get_path(".discloud_token").unwrap();
1012
std::fs::read_to_string(token_file)
1113
}
14+
#[tracing::instrument]
1215
pub fn validate_token() -> bool {
1316
match get_token() {
1417
Ok(token) => {

src/commands/aboutme.rs

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,62 @@
11
use chrono::{Datelike, Timelike};
22
use colored::Colorize;
33

4-
pub fn aboutme(){
4+
#[tracing::instrument]
5+
pub fn aboutme() {
56
let token = super::expect_token();
67
match crate::entities::user::fetch_user(token.clone()) {
78
Ok(user) => {
89
println!("ID: {}", user.user_id.bright_black());
910
println!("Plan: {}", color_plan(user.plan));
1011
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+
);
1324
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+
);
1743
println!("Locale: {}", user.locale.blue());
1844
}
19-
Err(err) => super::err(&err.to_string())
20-
}
45+
Err(err) => super::err(&err.to_string()),
46+
}
2147
}
48+
#[tracing::instrument]
2249
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+
}
5362
}

src/commands/apps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use colored::Colorize;
22

33
use crate::entities::FetchError;
4+
#[tracing::instrument]
45
pub fn apps() {
56
let token = super::expect_token();
67
match crate::entities::app::App::fetch_all(token.clone()) {

src/commands/authstatus.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::auth;
22
use std::io::ErrorKind;
3+
#[tracing::instrument]
34
pub fn authstatus() -> std::io::Result<()> {
45
match auth::get_token() {
56
Ok(token) => {

0 commit comments

Comments
 (0)