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

Function main

crates/chat-cli/build.rs:83–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83fn main() {
84 println!("cargo:rerun-if-changed=def.json");
85
86 // Download feed.json if FETCH_FEED environment variable is set
87 if std::env::var("FETCH_FEED").is_ok() {
88 download_feed_json();
89 }
90
91 #[cfg(target_os = "macos")]
92 write_plist();
93
94 let outdir = std::env::var("OUT_DIR").unwrap();
95
96 let data = serde_json::from_str::<Def>(DEF).unwrap();
97
98 let mut out = "
99 #[allow(rustdoc::invalid_html_tags)]
100 #[allow(rustdoc::bare_urls)]
101 mod inner {
102 "
103 .to_string();
104
105 out.push_str("pub mod types {");
106 for t in data.types {
107 let name = format_ident!("{}", t.name.to_case(Case::Pascal));
108
109 let rust_type = match t.allowed_values {
110 // enum
111 Some(allowed_values) => {
112 let mut variants = vec![];
113 let mut variant_as_str = vec![];
114
115 for v in allowed_values {
116 let ident = format_ident!("{}", v.replace('.', "").to_case(Case::Pascal));
117 variants.push(quote!(
118 #[doc = concat!("`", #v, "`")]
119 #ident
120 ));
121 variant_as_str.push(quote!(
122 #name::#ident => #v
123 ));
124 }
125
126 let description = t.description;
127
128 quote::quote!(
129 #[doc = #description]
130 #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
131 #[non_exhaustive]
132 pub enum #name {
133 #(
134 #variants,
135 )*
136 }
137
138 impl #name {
139 pub fn as_str(&self) -> &'static str {
140 match self {

Callers

nothing calls this directly

Calls 5

download_feed_jsonFunction · 0.85
write_plistFunction · 0.85
to_stringMethod · 0.80
mapMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected