3 files changed
+23
-33
src/constants.rs
+2
-2
@@ -1,10 +1,10 @@
1
use console::Emoji;
2
3
#[cfg(debug_assertions)]
4
-pub const BASE_URL: &'static str = "http://localhost:3000";
4
+pub const BASE_URL: &str = "http://localhost:3000/";
5
6
#[cfg(not(debug_assertions))]
7
-pub const BASE_URL: &'static str = "https://api.smbpndk.com/";
7
+pub const BASE_URL: &str = "https://api.smbpndk.com/";
8
9
pub const OK_EMOJI: Emoji<'_, '_> = Emoji("✅ ", "");
10
pub const ERROR_EMOJI: Emoji<'_, '_> = Emoji("❌ ", "");
src/main.rs
+20
-29
@@ -101,20 +101,16 @@ async fn run() -> Result<CommandResult> {
101
);
102
103
match process_login(LoginArgs { username, password }).await {
104
- Ok(_) => {
105
- return Ok(CommandResult {
106
- spinner: spinner,
107
- symbol: "✅".to_owned(),
108
- msg: "You are logged in!".to_owned(),
109
- });
110
- }
111
- Err(e) => {
112
- return Ok(CommandResult {
113
- spinner: spinner,
114
- symbol: "❌".to_owned(),
115
- msg: format!("Failed to login: {}", e),
116
- });
117
- }
104
+ Ok(_) => Ok(CommandResult {
105
+ spinner,
106
+ symbol: "✅".to_owned(),
107
+ msg: "You are logged in!".to_owned(),
108
+ }),
109
+ Err(e) => Ok(CommandResult {
110
+ spinner,
111
+ symbol: "❌".to_owned(),
112
+ msg: format!("Failed to login: {e}"),
113
+ }),
114
}
115
}
116
Commands::Signup {} => {
@@ -144,21 +140,16 @@ async fn run() -> Result<CommandResult> {
140
);
141
142
match process_signup(SignupArgs { username, password }).await {
147
- Ok(_) => {
148
- return Ok(CommandResult {
149
- spinner: spinner,
150
- symbol: "✅".to_owned(),
151
- msg: "You are signed up! Check your email to confirm your account."
152
- .to_owned(),
153
- });
154
- }
155
- Err(e) => {
156
- return Ok(CommandResult {
157
- spinner: spinner,
158
- symbol: "❌".to_owned(),
159
- msg: format!("Failed to signup: {}", e),
160
- });
161
- }
143
+ Ok(_) => Ok(CommandResult {
144
+ spinner,
145
+ symbol: "✅".to_owned(),
146
+ msg: "You are signed up! Check your email to confirm your account.".to_owned(),
147
+ }),
148
+ Err(e) => Ok(CommandResult {
149
+ spinner,
150
+ symbol: "❌".to_owned(),
151
+ msg: format!("Failed to signup: {e}"),
152
+ }),
153
}
154
}
155
}
src/signup/process.rs
+1
-2
@@ -1,7 +1,6 @@
1
use anyhow::{anyhow, Result};
2
use reqwest::Client;
3
use serde::Serialize;
4
-use tokio::sync::watch::error;
4
5
use crate::{constants::BASE_URL, login::User};
6
pub struct SignupArgs {
@@ -30,7 +29,7 @@ pub async fn process_signup(args: SignupArgs) -> Result<()> {
29
reqwest::StatusCode::OK => {
30
let headers = response.headers();
31
let token = headers.get("Authorization").unwrap().to_str().unwrap();
33
- println!("token: {}", token);
32
+ println!("token: {token}");
33
}
34
_ => {
35
let error = anyhow!("Failed to signup: {}", response.status());