Applied formatting
This commit is contained in:
+11
-11
@@ -9,8 +9,8 @@ use anyhow::{Context, Result};
|
|||||||
use inquire::{validator::Validation, Text};
|
use inquire::{validator::Validation, Text};
|
||||||
use rust_embed::Embed;
|
use rust_embed::Embed;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fs, fs::read_to_string, path::Path};
|
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::{fs, fs::read_to_string, path::Path};
|
||||||
|
|
||||||
const DEFAULT_AGENT_NAME: &str = "rag";
|
const DEFAULT_AGENT_NAME: &str = "rag";
|
||||||
|
|
||||||
@@ -47,11 +47,11 @@ impl Agent {
|
|||||||
.ok_or_else(|| anyhow!("Failed to load embedded agent file: {}", file.as_ref()))?;
|
.ok_or_else(|| anyhow!("Failed to load embedded agent file: {}", file.as_ref()))?;
|
||||||
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
|
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
|
||||||
let file_path = Config::agents_data_dir().join(file.as_ref());
|
let file_path = Config::agents_data_dir().join(file.as_ref());
|
||||||
let file_extension = file_path
|
let file_extension = file_path
|
||||||
.extension()
|
.extension()
|
||||||
.and_then(OsStr::to_str)
|
.and_then(OsStr::to_str)
|
||||||
.map(|s| s.to_lowercase());
|
.map(|s| s.to_lowercase());
|
||||||
let is_script = matches!(file_extension.as_deref(), Some("sh") | Some("py"));
|
let is_script = matches!(file_extension.as_deref(), Some("sh") | Some("py"));
|
||||||
|
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
debug!(
|
debug!(
|
||||||
@@ -66,11 +66,11 @@ impl Agent {
|
|||||||
let mut agent_file = File::create(&file_path)?;
|
let mut agent_file = File::create(&file_path)?;
|
||||||
agent_file.write_all(content.as_bytes())?;
|
agent_file.write_all(content.as_bytes())?;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
if is_script {
|
if is_script {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
fs::set_permissions(&file_path, fs::Permissions::from_mode(0o755))?;
|
fs::set_permissions(&file_path, fs::Permissions::from_mode(0o755))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+10
-10
@@ -137,11 +137,11 @@ impl Functions {
|
|||||||
})?;
|
})?;
|
||||||
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
|
let content = unsafe { std::str::from_utf8_unchecked(&embedded_file.data) };
|
||||||
let file_path = Config::functions_dir().join(file.as_ref());
|
let file_path = Config::functions_dir().join(file.as_ref());
|
||||||
let file_extension = file_path
|
let file_extension = file_path
|
||||||
.extension()
|
.extension()
|
||||||
.and_then(OsStr::to_str)
|
.and_then(OsStr::to_str)
|
||||||
.map(|s| s.to_lowercase());
|
.map(|s| s.to_lowercase());
|
||||||
let is_script = matches!(file_extension.as_deref(), Some("sh") | Some("py"));
|
let is_script = matches!(file_extension.as_deref(), Some("sh") | Some("py"));
|
||||||
|
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
debug!(
|
debug!(
|
||||||
@@ -156,11 +156,11 @@ impl Functions {
|
|||||||
let mut function_file = File::create(&file_path)?;
|
let mut function_file = File::create(&file_path)?;
|
||||||
function_file.write_all(content.as_bytes())?;
|
function_file.write_all(content.as_bytes())?;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
if is_script {
|
if is_script {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
fs::set_permissions(&file_path, fs::Permissions::from_mode(0o755))?;
|
fs::set_permissions(&file_path, fs::Permissions::from_mode(0o755))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user