MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / create_example_file

Method create_example_file

aiscript/src/project.rs:102–123  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

100 }
101
102 fn create_example_file(&self) -> Result<(), String> {
103 let routes_dir = self.project_path.join("routes");
104 let example_path = routes_dir.join("index.ai");
105
106 let example_content = r#"// Example AIScript route handler
107get /hello {
108 query {
109 name: str
110 }
111
112 return { message: f"Hello, {query.name}!" };
113}
114"#;
115
116 let mut file = fs::File::create(&example_path)
117 .map_err(|e| format!("Failed to create example file: {}", e))?;
118
119 file.write_all(example_content.as_bytes())
120 .map_err(|e| format!("Failed to write to example file: {}", e))?;
121
122 Ok(())
123 }
124
125 fn display_project_structure(&self) -> String {
126 let mut result = format!("{}\n", self.project_name);

Callers 1

generateMethod · 0.80

Calls 1

as_bytesMethod · 0.80

Tested by

no test coverage detected