|
4 | 4 | console::style, |
5 | 5 | smbcloud_cli::{ |
6 | 6 | account::{login::process_login, logout::process_logout, me::process_me, process_account}, |
| 7 | + clear_smb_token, |
7 | 8 | cli::{Cli, CommandResult, Commands}, |
8 | 9 | deploy::process_deploy::process_deploy, |
9 | 10 | project::{crud_create::process_project_init, process::process_project}, |
@@ -72,25 +73,34 @@ fn setup_logging(env: Environment, level: Option<EnvFilter>) -> Result<()> { |
72 | 73 |
|
73 | 74 | #[tokio::main] |
74 | 75 | async fn main() { |
75 | | - match run().await { |
| 76 | + let cli = Cli::parse(); |
| 77 | + let environment = cli.environment; |
| 78 | + match run(cli).await { |
76 | 79 | Ok(result) => { |
77 | 80 | result.stop_and_persist(); |
78 | 81 | std::process::exit(0); |
79 | 82 | } |
80 | 83 | Err(e) => { |
81 | | - println!( |
82 | | - "\n{} {}", |
83 | | - style("✘".to_string()).for_stderr().red(), |
84 | | - style(e).red() |
85 | | - ); |
| 84 | + if e.to_string().contains("Unauthorized access.") { |
| 85 | + let _ = clear_smb_token(environment); |
| 86 | + println!( |
| 87 | + "\n{} {}", |
| 88 | + style("✘".to_string()).for_stderr().red(), |
| 89 | + style("Your session has expired. Please login again with `smb login`.").red() |
| 90 | + ); |
| 91 | + } else { |
| 92 | + println!( |
| 93 | + "\n{} {}", |
| 94 | + style("✘".to_string()).for_stderr().red(), |
| 95 | + style(e).red() |
| 96 | + ); |
| 97 | + } |
86 | 98 | std::process::exit(1); |
87 | 99 | } |
88 | 100 | } |
89 | 101 | } |
90 | 102 |
|
91 | | -async fn run() -> Result<CommandResult> { |
92 | | - let cli = Cli::parse(); |
93 | | - |
| 103 | +async fn run(cli: Cli) -> Result<CommandResult> { |
94 | 104 | // println!("Environment: {}", cli.environment); |
95 | 105 |
|
96 | 106 | let log_level_error: Result<CommandResult> = Err(anyhow!( |
|
0 commit comments