@smbcloud / cli / commits / c799d15

same

Seto Elkahfi committed May 27, 2025 at 19:31 UTC c799d15fa5b3336abb56316249273ddc11fcd0ee
4 files changed +28 -30
crates/cli/src/account/forgot/mod.rs
+1 -2
@@ -3,7 +3,6 @@ use crate::{
3 ui::{fail_message, fail_symbol, succeed_message, succeed_symbol},
4 };
5 use anyhow::Result;
6 -use console::style;
6 use dialoguer::{theme::ColorfulTheme, Input, Password};
7 use reqwest::{Client, StatusCode};
8 use serde::{Deserialize, Serialize};
@@ -23,7 +22,7 @@ pub async fn process_forgot(env: Environment) -> Result<CommandResult> {
22 .unwrap();
23 let mut spinner = Spinner::new(
24 spinners::Spinners::SimpleDotsScrolling,
26 - style("Checking email").green().bold().to_string(),
25 + succeed_message("Checking email"),
26 );
27
28 let params = Args {
crates/cli/src/account/login/process.rs
+2 -5
@@ -236,7 +236,7 @@ async fn connect_github_account(env: Environment, auth: SmbAuthorization) -> Res
236 if !confirm {
237 let spinner = Spinner::new(
238 spinners::Spinners::SimpleDotsScrolling,
239 - style("Cancel operation.").green().bold().to_string(),
239 + succeed_message("Cancel operation."),
240 );
241 return Ok(CommandResult {
242 spinner,
@@ -247,10 +247,7 @@ async fn connect_github_account(env: Environment, auth: SmbAuthorization) -> Res
247
248 let spinner = Spinner::new(
249 spinners::Spinners::SimpleDotsScrolling,
250 - style("Linking your GitHub account...")
251 - .green()
252 - .bold()
253 - .to_string(),
250 + succeed_message("Linking your GitHub account..."),
251 );
252
253 let response = Client::new()
crates/cli/src/account/logout/mod.rs
+4 -5
@@ -1,5 +1,4 @@
1 use anyhow::{anyhow, Result};
2 -use console::style;
2 use dialoguer::{theme::ColorfulTheme, Confirm};
3 use reqwest::{Client, StatusCode};
4 use smbcloud_networking::{
@@ -31,16 +30,16 @@ pub async fn process_logout(env: Environment) -> Result<CommandResult> {
30 return Ok(CommandResult {
31 spinner: Spinner::new(
32 spinners::Spinners::SimpleDotsScrolling,
34 - style("Cancel operation.").green().bold().to_string(),
33 + succeed_message("Cancel operation"),
34 ),
35 symbol: succeed_symbol(),
37 - msg: "Doing nothing.".to_owned(),
36 + msg: succeed_message("Doing nothing."),
37 });
38 }
39
40 let spinner = Spinner::new(
41 spinners::Spinners::SimpleDotsScrolling,
43 - style("Logging you out...").green().bold().to_string(),
42 + succeed_message("Logging you out"),
43 );
44
45 // Call backend
@@ -59,7 +58,7 @@ pub async fn process_logout(env: Environment) -> Result<CommandResult> {
58 Ok(CommandResult {
59 spinner: Spinner::new(
60 spinners::Spinners::SimpleDotsScrolling,
62 - style("Loading...").green().bold().to_string(),
61 + succeed_message("Loading"),
62 ),
63 symbol: fail_symbol(),
64 msg: fail_message("You are not logged in. Please login first."),
crates/cli/src/account/signup/process.rs
+21 -18
@@ -1,7 +1,11 @@
1 use super::SignupMethod;
2 -use crate::{account::lib::authorize_github, cli::CommandResult, ui::fail_symbol};
2 +use crate::{
3 + account::lib::authorize_github,
4 + cli::CommandResult,
5 + ui::{fail_message, fail_symbol, succeed_message, succeed_symbol},
6 +};
7 use anyhow::{anyhow, Result};
4 -use console::{style, Term};
8 +use console::Term;
9 use dialoguer::{theme::ColorfulTheme, Input, Password, Select};
10 use log::debug;
11 use reqwest::{Client, StatusCode};
@@ -19,10 +23,10 @@ pub async fn process_signup(env: Environment) -> Result<CommandResult> {
23 return Ok(CommandResult {
24 spinner: Spinner::new(
25 spinners::Spinners::SimpleDotsScrolling,
22 - style("Loading...").green().bold().to_string(),
26 + succeed_message("Loading"),
27 ),
28 symbol: fail_symbol(),
25 - msg: "You are already logged in. Please logout first.".to_owned(),
29 + msg: fail_message("You are already logged in. Please logout first."),
30 });
31 }
32
@@ -66,7 +70,7 @@ pub async fn signup_with_email(env: Environment, email: Option<String>) -> Resul
70
71 let spinner = Spinner::new(
72 spinners::Spinners::BouncingBall,
69 - style("Signing up...").green().bold().to_string(),
73 + succeed_message("Signing up"),
74 );
75
76 let params = SignupEmailParams {
@@ -76,13 +80,13 @@ pub async fn signup_with_email(env: Environment, email: Option<String>) -> Resul
80 match do_signup(env, &params).await {
81 Ok(_) => Ok(CommandResult {
82 spinner,
79 - symbol: style("✅".to_string()).for_stderr().green().to_string(),
80 - msg: "You are signed up! Check your email to confirm your account.".to_owned(),
83 + symbol: succeed_symbol(),
84 + msg: succeed_message("You are signed up! Check your email to confirm your account."),
85 }),
86 Err(e) => Ok(CommandResult {
87 spinner,
84 - symbol: style("✘".to_string()).for_stderr().red().to_string(),
85 - msg: format!("{e}"),
88 + symbol: fail_symbol(),
89 + msg: fail_message(&format!("{e}")),
90 }),
91 }
92 }
@@ -94,13 +98,10 @@ async fn signup_with_github(env: Environment) -> Result<CommandResult> {
98 Ok(CommandResult {
99 spinner: Spinner::new(
100 spinners::Spinners::BouncingBall,
97 - style("Requesting GitHub token...")
98 - .green()
99 - .bold()
100 - .to_string(),
101 + succeed_message("Requesting GitHub token"),
102 ),
102 - symbol: style("✅".to_string()).for_stderr().green().to_string(),
103 - msg: "Finished requesting GitHub token!".to_owned(),
103 + symbol: succeed_symbol(),
104 + msg: succeed_message("Finished requesting GitHub token!"),
105 })
106 }
107 Err(e) => {
@@ -113,7 +114,7 @@ async fn signup_with_github(env: Environment) -> Result<CommandResult> {
114 pub async fn do_signup<T: Serialize + ?Sized>(env: Environment, args: &T) -> Result<CommandResult> {
115 let spinner = Spinner::new(
116 spinners::Spinners::BouncingBall,
116 - style("Signing you up...").green().bold().to_string(),
117 + succeed_message("Signing you up"),
118 );
119
120 let response = Client::new()
@@ -125,8 +126,10 @@ pub async fn do_signup<T: Serialize + ?Sized>(env: Environment, args: &T) -> Res
126 match response.status() {
127 StatusCode::OK => Ok(CommandResult {
128 spinner,
128 - symbol: "✅".to_owned(),
129 - msg: "Your account has been created. Check email for verification link.".to_owned(),
129 + symbol: succeed_symbol(),
130 + msg: succeed_message(
131 + "Your account has been created. Check email for verification link.",
132 + ),
133 }),
134 StatusCode::UNPROCESSABLE_ENTITY => {
135 let result: SignupResult = response.json().await?;