(self, os: &mut Os, session: &mut ChatSession)
| 37 | |
| 38 | impl SubscribeArgs { |
| 39 | pub async fn execute(self, os: &mut Os, session: &mut ChatSession) -> Result<ChatState, ChatError> { |
| 40 | if is_idc_user(&os.database) |
| 41 | .await |
| 42 | .map_err(|e| ChatError::Custom(e.to_string().into()))? |
| 43 | { |
| 44 | execute!( |
| 45 | session.stderr, |
| 46 | StyledText::warning_fg(), |
| 47 | style::Print("\nYour Q Developer Pro subscription is managed through IAM Identity Center.\n\n"), |
| 48 | StyledText::reset(), |
| 49 | )?; |
| 50 | } else if self.manage { |
| 51 | queue!(session.stderr, style::Print("\n"),)?; |
| 52 | match get_subscription_status_with_spinner(os, &mut session.stderr).await { |
| 53 | Ok(status) => { |
| 54 | if status != ActualSubscriptionStatus::Active { |
| 55 | queue!( |
| 56 | session.stderr, |
| 57 | StyledText::warning_fg(), |
| 58 | style::Print("You don't seem to have a Q Developer Pro subscription. "), |
| 59 | StyledText::secondary_fg(), |
| 60 | style::Print("Use "), |
| 61 | StyledText::success_fg(), |
| 62 | style::Print("/subscribe"), |
| 63 | StyledText::secondary_fg(), |
| 64 | style::Print(" to upgrade your subscription.\n\n"), |
| 65 | StyledText::reset(), |
| 66 | )?; |
| 67 | } |
| 68 | }, |
| 69 | Err(err) => { |
| 70 | queue!( |
| 71 | session.stderr, |
| 72 | StyledText::error_fg(), |
| 73 | style::Print(format!("Failed to get subscription status: {}\n\n", err)), |
| 74 | StyledText::reset(), |
| 75 | )?; |
| 76 | }, |
| 77 | } |
| 78 | |
| 79 | let url = format!( |
| 80 | "https://{}.console.aws.amazon.com/amazonq/developer/home#/subscriptions", |
| 81 | os.database |
| 82 | .get_idc_region() |
| 83 | .ok() |
| 84 | .flatten() |
| 85 | .unwrap_or("us-east-1".to_string()) |
| 86 | ); |
| 87 | if is_remote() || crate::util::open::open_url_async(&url).await.is_err() { |
| 88 | execute!( |
| 89 | session.stderr, |
| 90 | style::Print(format!("Open this URL to manage your subscription: {}\n\n", url.blue())), |
| 91 | StyledText::reset(), |
| 92 | StyledText::reset(), |
| 93 | )?; |
| 94 | } |
| 95 | } else { |
| 96 | upgrade_to_pro(os, session).await?; |
nothing calls this directly
no test coverage detected