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

Method create_url

crates/chat-cli/src/cli/chat/util/issue.rs:29–83  ·  view source on GitHub ↗
(&self, os: &Os)

Source from the content-addressed store, hash-verified

27
28impl IssueCreator {
29 pub async fn create_url(&self, os: &Os) -> Result<url::Url> {
30 println!("Heading over to GitHub...");
31
32 let warning = |text: &String| {
33 format!("<This will be visible to anyone. Do not include personal or sensitive information>\n\n{text}")
34 };
35 let diagnostics = Diagnostics::new(&os.env).await;
36
37 let os = match &diagnostics.system_info.os {
38 Some(os) => os.to_string(),
39 None => "None".to_owned(),
40 };
41
42 let diagnostic_info = match diagnostics.user_readable() {
43 Ok(diagnostics) => diagnostics,
44 Err(err) => {
45 eprintln!("Error getting diagnostics: {err}");
46 "Error occurred while generating diagnostics".to_owned()
47 },
48 };
49
50 let environment = match &self.additional_environment {
51 Some(os) => format!("{diagnostic_info}\n{os}"),
52 None => diagnostic_info,
53 };
54
55 let mut params = Vec::new();
56 params.push(("template", TEMPLATE_NAME.to_string()));
57 params.push(("os", os));
58 params.push(("environment", warning(&environment)));
59
60 if let Some(t) = self.title.clone() {
61 params.push(("title", t));
62 }
63 if let Some(t) = self.expected_behavior.as_ref() {
64 params.push(("expected", warning(t)));
65 }
66 if let Some(t) = self.actual_behavior.as_ref() {
67 params.push(("actual", warning(t)));
68 }
69 if let Some(t) = self.steps_to_reproduce.as_ref() {
70 params.push(("reproduce", warning(t)));
71 }
72
73 let url = url::Url::parse_with_params(
74 &format!("https://github.com/{GITHUB_REPO_NAME}/issues/new"),
75 params.iter(),
76 )?;
77
78 if is_remote() || crate::util::open::open_url_async(url.as_str()).await.is_err() {
79 println!("Issue Url: {}", url.as_str().underlined());
80 }
81
82 Ok(url)
83 }
84}

Callers 2

executeMethod · 0.80
invokeMethod · 0.80

Calls 7

is_remoteFunction · 0.85
open_url_asyncFunction · 0.85
to_stringMethod · 0.80
user_readableMethod · 0.80
cloneMethod · 0.45
as_refMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected