Skip to content

Commit cfe339e

Browse files
committed
fixing params
1 parent de8f93b commit cfe339e

3 files changed

Lines changed: 59 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust_tui_coder"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
description = "AI-powered terminal coding assistant with interactive TUI, supporting multiple LLMs and comprehensive development tools"
66
license = "MIT OR Apache-2.0"

src/main.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,71 @@ use ratatui::{
1616
backend::{Backend, CrosstermBackend},
1717
Terminal,
1818
};
19+
use std::fs;
1920
use std::io;
2021
use std::sync::Arc;
2122
use std::time::Duration;
2223
use tokio::sync::Mutex;
2324
use tokio::task;
2425

26+
fn create_default_config() -> io::Result<()> {
27+
let default_config = r#"# Configuration for the LLM API
28+
[llm]
29+
provider = "openai"
30+
31+
api_key = ""
32+
33+
api_base_url = "http://localhost:11434/v1"
34+
35+
# Set to a concrete model name or use AUTODETECT to pick the first model from /v1/models
36+
model_name = "AUTODETECT"
37+
38+
39+
40+
# Automation options
41+
max_attempts = 12
42+
workspace_root = ""
43+
shell = "bash"
44+
post_write_verify = true
45+
safe_fs = true
46+
"#;
47+
48+
fs::write("config.toml", default_config)?;
49+
Ok(())
50+
}
51+
2552
#[tokio::main]
2653
async fn main() -> Result<(), Box<dyn std::error::Error>> {
54+
// Check if config.toml exists, if not prompt user to create it
55+
if !std::path::Path::new("config.toml").exists() {
56+
eprintln!("Error: config.toml not found!");
57+
eprintln!();
58+
eprintln!("A configuration file is required to run this application.");
59+
eprintln!("Would you like to create a default config.toml? (y/n)");
60+
61+
let mut input = String::new();
62+
io::stdin().read_line(&mut input)?;
63+
64+
if input.trim().to_lowercase() == "y" {
65+
create_default_config()?;
66+
eprintln!();
67+
eprintln!("✓ Created config.toml with default values.");
68+
eprintln!();
69+
eprintln!("IMPORTANT: Please edit config.toml and set your LLM configuration:");
70+
eprintln!(" - api_key: Your API key");
71+
eprintln!(" - api_base_url: Your LLM API endpoint");
72+
eprintln!(" - model_name: The model to use (or 'AUTODETECT')");
73+
eprintln!();
74+
eprintln!("Run the application again after configuring.");
75+
return Ok(());
76+
} else {
77+
eprintln!();
78+
eprintln!("Please create a config.toml file manually.");
79+
eprintln!("You can use config_example.toml as a reference.");
80+
return Err("Configuration file not found".into());
81+
}
82+
}
83+
2784
// Load configuration
2885
let config = Config::from_file("config.toml")?;
2986

0 commit comments

Comments
 (0)