Rebrand to Galaxy, major improvements to Bedrock support, still needs some TLC though
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "sample-project"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
@@ -0,0 +1,19 @@
|
||||
# Sample Project
|
||||
|
||||
A simple Rust project used for testing the Warp AI Bedrock integration.
|
||||
|
||||
## Features
|
||||
- Configuration from environment variables
|
||||
- Basic math utilities
|
||||
- File reading helpers
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
cargo run
|
||||
```
|
||||
|
||||
Set environment variables:
|
||||
- `APP_NAME` - Application name (default: "sample-app")
|
||||
- `PORT` - Server port (default: 8080)
|
||||
- `DEBUG` - Enable debug mode (set to "1")
|
||||
@@ -0,0 +1,24 @@
|
||||
pub mod utils;
|
||||
|
||||
pub fn add(a: i32, b: i32) -> i32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
pub fn multiply(a: i32, b: i32) -> i32 {
|
||||
a * b
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_add() {
|
||||
assert_eq!(add(2, 3), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiply() {
|
||||
assert_eq!(multiply(3, 4), 12);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct Config {
|
||||
name: String,
|
||||
port: u16,
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
fn from_env() -> Self {
|
||||
Self {
|
||||
name: std::env::var("APP_NAME").unwrap_or_else(|_| "sample-app".into()),
|
||||
port: std::env::var("PORT")
|
||||
.ok()
|
||||
.and_then(|p| p.parse().ok())
|
||||
.unwrap_or(8080),
|
||||
debug: std::env::var("DEBUG").map(|v| v == "1").unwrap_or(false),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let config = Config::from_env();
|
||||
println!("Starting {} on port {}", config.name, config.port);
|
||||
if config.debug {
|
||||
println!("Debug mode enabled");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
use std::path::Path;
|
||||
|
||||
pub fn file_exists(path: &str) -> bool {
|
||||
Path::new(path).exists()
|
||||
}
|
||||
|
||||
pub fn read_lines(path: &str) -> Result<Vec<String>, std::io::Error> {
|
||||
use std::io::BufRead;
|
||||
let file = std::fs::File::open(path)?;
|
||||
let reader = std::io::BufReader::new(file);
|
||||
reader.lines().collect()
|
||||
}
|
||||
Reference in New Issue
Block a user