You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-36Lines changed: 40 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,21 +113,21 @@ The API provides the following endpoints:
113
113
114
114
#### 📤 Response:
115
115
116
-
```
117
-
[filename: Cargo.toml]
118
-
[package]
119
-
name = "calculator"
120
-
version = "0.1.0"
121
-
edition = "2021"
122
-
123
-
[dependencies]
124
-
... ...
116
+
The `combined_text` field contains the flat text output of Rust project files that can be used as input for `/compile` and `/compile-and-fix` API calls.
125
117
126
-
[filename: src/main.rs]
127
-
fn main() {
128
-
// Calculator implementation
118
+
```
119
+
{
120
+
"success": true,
121
+
"message":"Project generated successfully",
122
+
"combined_text":"[filename: Cargo.toml]\n[package]\nname = \"calculator\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nclap = { version = \"4.5\", features = [\"derive\"] }\n\n[filename: src/main.rs]\nuse std::io;\nuse clap::Parser;\n\n#[derive(Parser, Debug)]\n#[command(author, version, about, long_about = None)]\nstruct Args {\n /// The first number\n #[arg(required = true)]\n num1: f64,\n /// Operator (+, -, *, /)\n #[arg(required = true, value_parser = clap::value_parser!(f64))]\n operator: String,\n /// The second number\n #[arg(required = true)]\n num2: f64,\n}\n\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n let args = Args::parse();\n\n match args.operator.as_str() {\n \"+\" => {\n println!(\"{}\", args.num1 + args.num2);\n }\n \"-\" => {\n println!(\"{}\", args.num1 - args.num2);\n }\n \"*\" => {\n println!(\"{}\", args.num1 * args.num2);\n }\n \"/\" => {\n if args.num2 == 0.0 {\n eprintln!(\"Error: Cannot divide by zero.\");\n std::process::exit(1);\n }\n println!(\"{}\", args.num1 / args.num2);\n }\n _ => {\n eprintln!(\"Error: Invalid operator. Use +, -, *, or /\");\n std::process::exit(1);\n }\n }\n\n Ok(())\n}\n\n[filename: README.md]\n# Calculator\n\nA simple command-line calculator written in Rust. Supports addition, subtraction, multiplication, and division.\n\n## Usage\n\nRun the program with two numbers and an operator as arguments:\n\n```bash\ncargo run <num1> <operator> <num2>\n```\n\nWhere `<operator>` is one of `+`, `-`, `*`, or `/`.\n\n**Example:**\n\n```bash\ncargo run 5 + 3\n# Output: 8\n\ncargo run 10 / 2\n# Output: 5\n\ncargo run 7 * 4\n# Output: 28\n```\n\n## Error Handling\n\nThe calculator handles division by zero and invalid operator inputs. Error messages are printed to standard error, and the program exits with a non-zero exit code in case of an error.\n\n\n# Build succeeded",
123
+
"files":{
124
+
"Cargo.toml":"[package]\nname = \"calculator\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nclap = { version = \"4.5\", features = [\"derive\"] }",
"README.md":"# Calculator\n\nA simple command-line calculator written in Rust. Supports addition, subtraction, multiplication, and division.\n\n## Usage\n\nRun the program with two numbers and an operator as arguments:\n\n```bash\ncargo run <num1> <operator> <num2>\n```\n\nWhere `<operator>` is one of `+`, `-`, `*`, or `/`.\n\n**Example:**\n\n```bash\ncargo run 5 + 3\n# Output: 8\n\ncargo run 10 / 2\n# Output: 5\n\ncargo run 7 * 4\n# Output: 28\n```\n\n## Error Handling\n\nThe calculator handles division by zero and invalid operator inputs. Error messages are printed to standard error, and the program exits with a non-zero exit code in case of an error."
127
+
},
128
+
"build_output":null,
129
+
"build_success":true
129
130
}
130
-
... ...
131
131
```
132
132
133
133
### 🛠 Compile a Project
@@ -176,7 +176,7 @@ curl -X POST http://localhost:8000/compile \
176
176
curl -X POST http://localhost:8000/compile-and-fix \
"output":" Compiling hello_world v0.1.0 (/tmp/tmpbgeg4x_e)\nerror: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `\"Hello, World!\"`\n --> src/main.rs:2:11\n |\n2 | print \"Hello, World!\" \n | ^^^^^^^^^^^^^^^ expected one of 8 possible tokens\n\nerror: could not compile `hello_world` (bin \"hello_world\") due to 1 previous error\n"
208
+
},
209
+
{
210
+
"attempt":2,
211
+
"success":true,
212
+
"output":null
213
+
}
214
+
],
215
+
"combined_text":"[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}\n\n[filename: README.md]\n# Hello World\n\nThis is a simple \"Hello, World!\" program in Rust. It prints the message \"Hello, World!\" to the console.\n\nTo run it:\n\n1. Make sure you have Rust installed ([https://www.rust-lang.org/](https://www.rust-lang.org/)).\n2. Save the code as `src/main.rs`.\n3. Run `cargo run` in the terminal from the project directory.",
216
+
"files":{
217
+
"Cargo.toml":"[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]",
"README.md":"# Hello World\n\nThis is a simple \"Hello, World!\" program in Rust. It prints the message \"Hello, World!\" to the console.\n\nTo run it:\n\n1. Make sure you have Rust installed ([https://www.rust-lang.org/](https://www.rust-lang.org/)).\n2. Save the code as `src/main.rs`.\n3. Run `cargo run` in the terminal from the project directory."
0 commit comments