Breaking out some portions for integration testing.

This commit is contained in:
Micheal Smith
2025-11-10 22:20:09 -06:00
parent 3af95235e6
commit 2da7cc4450
4 changed files with 31 additions and 44 deletions

View File

@@ -1,19 +0,0 @@
use color_eyre::Result;
use std::path::{Path, PathBuf};
#[derive(Clone, Debug)]
pub struct Root {
path: PathBuf,
}
impl Root {
pub fn new(path: impl AsRef<Path>) -> Self {
Root {
path: path.as_ref().to_owned(),
}
}
pub fn run_command(_cmd_string: impl AsRef<str>) -> Result<()> {
todo!();
}
}

12
src/lib.rs Normal file
View File

@@ -0,0 +1,12 @@
// Robotnik libraries
pub mod chat;
pub mod event;
pub mod event_manager;
pub mod ipc;
pub mod qna;
pub mod setup;
pub use event::Event;
pub use event_manager::EventManager;
pub use qna::LLMHandle;

View File

@@ -4,13 +4,7 @@ use std::{os::unix::fs, sync::Arc};
use tracing::{Level, info}; use tracing::{Level, info};
use tracing_subscriber::FmtSubscriber; use tracing_subscriber::FmtSubscriber;
use crate::event_manager::EventManager; use robotnik::{chat, Event, EventManager, qna, setup};
mod chat;
mod event;
mod event_manager;
mod qna;
mod setup;
const DEFAULT_INSTRUCT: &str = const DEFAULT_INSTRUCT: &str =
"You are a shady, yet helpful IRC bot. You try to give responses that can "You are a shady, yet helpful IRC bot. You try to give responses that can
@@ -67,7 +61,7 @@ async fn main() -> Result<()> {
let ev_manager = Arc::new(EventManager::new()?); let ev_manager = Arc::new(EventManager::new()?);
let ev_manager_clone = Arc::clone(&ev_manager); let ev_manager_clone = Arc::clone(&ev_manager);
ev_manager_clone ev_manager_clone
.broadcast(&event::Event::new("Starting...")) .broadcast(&Event::new("Starting..."))
.await?; .await?;
let mut c = chat::new(&config, &handle).await?; let mut c = chat::new(&config, &handle).await?;

View File

@@ -8,65 +8,65 @@ use tracing::{info, instrument};
// TODO: use [clap(long, short, help_heading = Some(section))] // TODO: use [clap(long, short, help_heading = Some(section))]
#[derive(Clone, Debug, Parser)] #[derive(Clone, Debug, Parser)]
#[command(about, version)] #[command(about, version)]
pub(crate) struct Args { pub struct Args {
#[arg(short, long)] #[arg(short, long)]
/// API Key for the LLM in use. /// API Key for the LLM in use.
pub(crate) api_key: Option<String>, pub api_key: Option<String>,
#[arg(short, long, default_value = "https://api.openai.com")] #[arg(short, long, default_value = "https://api.openai.com")]
/// Base URL for the LLM API to use. /// Base URL for the LLM API to use.
pub(crate) base_url: Option<String>, pub base_url: Option<String>,
/// Directory to use for chroot (recommended). /// Directory to use for chroot (recommended).
#[arg(long)] #[arg(long)]
pub(crate) chroot_dir: Option<String>, pub chroot_dir: Option<String>,
/// Root directory for file based command structure. /// Root directory for file based command structure.
#[arg(long)] #[arg(long)]
pub(crate) command_dir: Option<String>, pub command_dir: Option<String>,
#[arg(long)] #[arg(long)]
/// Instructions to the model on how to behave. /// Instructions to the model on how to behave.
pub(crate) instruct: Option<String>, pub instruct: Option<String>,
#[arg(long)] #[arg(long)]
pub(crate) model: Option<String>, pub model: Option<String>,
#[arg(long)] #[arg(long)]
/// List of IRC channels to join. /// List of IRC channels to join.
pub(crate) channels: Option<Vec<String>>, pub channels: Option<Vec<String>>,
#[arg(short, long)] #[arg(short, long)]
/// Custom configuration file location if need be. /// Custom configuration file location if need be.
pub(crate) config_file: Option<PathBuf>, pub config_file: Option<PathBuf>,
#[arg(short, long, default_value = "irc.libera.chat")] #[arg(short, long, default_value = "irc.libera.chat")]
/// IRC server. /// IRC server.
pub(crate) server: Option<String>, pub server: Option<String>,
#[arg(short, long, default_value = "6697")] #[arg(short, long, default_value = "6697")]
/// Port of the IRC server. /// Port of the IRC server.
pub(crate) port: Option<String>, pub port: Option<String>,
#[arg(long)] #[arg(long)]
/// IRC Nickname. /// IRC Nickname.
pub(crate) nickname: Option<String>, pub nickname: Option<String>,
#[arg(long)] #[arg(long)]
/// IRC Nick Password /// IRC Nick Password
pub(crate) nick_password: Option<String>, pub nick_password: Option<String>,
#[arg(long)] #[arg(long)]
/// IRC Username /// IRC Username
pub(crate) username: Option<String>, pub username: Option<String>,
#[arg(long)] #[arg(long)]
/// Whether or not to use TLS when connecting to the IRC server. /// Whether or not to use TLS when connecting to the IRC server.
pub(crate) use_tls: Option<bool>, pub use_tls: Option<bool>,
} }
pub(crate) struct Setup { pub struct Setup {
pub(crate) config: Config, pub config: Config,
} }
#[instrument] #[instrument]