MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / execute

Method execute

crates/chat-cli/src/cli/chat/cli/subscribe.rs:39–102  ·  view source on GitHub ↗
(self, os: &mut Os, session: &mut ChatSession)

Source from the content-addressed store, hash-verified

37
38impl 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?;

Callers

nothing calls this directly

Calls 7

is_idc_userFunction · 0.85
CustomClass · 0.85
is_remoteFunction · 0.85
open_url_asyncFunction · 0.85
upgrade_to_proFunction · 0.85
to_stringMethod · 0.80

Tested by

no test coverage detected