feat: 模块统一 ias- 前缀、独立版本与内网地址支持 (0.1.7)
- 所有 Rust crate 统一加 ias- 前缀:ai → ias-ai、common → ias-common、context → ias-context、mail → ias-mail、service → ias-service、wechat → ias-wechat - 新增 ias-main 模块承载 CLI 入口和二进制打包 - 各模块开始独立维护版本号,ias-main 0.1.7 代表整体版本 - 新增 IA_WEB_INTERNAL_URL 环境变量,版本通知同时发送公网和内网链接 - 将已有升级日志翻译为中文 - ias_upgrade_logs 新增 modules JSONB 字段 - 新增 VERSION 文件和 CHANGELOG.md - 新增 AGENTS.md 项目规则文件
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "ias-main"
|
||||
version = "0.1.7"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "ias-main"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
ias-service = { path = "../ias-service" }
|
||||
ias-mail = { path = "../ias-mail" }
|
||||
clap = { version = "4.6.1", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
sqlx = { version = "0.9.0", features = [
|
||||
"runtime-tokio",
|
||||
"tls-rustls",
|
||||
"postgres",
|
||||
"migrate",
|
||||
"chrono",
|
||||
] }
|
||||
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }
|
||||
dotenvy = "0.15.7"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
@@ -0,0 +1,89 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "ias")]
|
||||
#[command(version)]
|
||||
#[command(about = "Rust驱动的智能AI助手。")]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Commands {
|
||||
/// 启动服务
|
||||
Service {
|
||||
#[command(subcommand)]
|
||||
command: Option<ServiceAction>,
|
||||
},
|
||||
/// 配置邮件账户
|
||||
Mail {
|
||||
#[command(subcommand)]
|
||||
command: MailAction,
|
||||
},
|
||||
/// 配置渠道
|
||||
Channel {
|
||||
#[command(subcommand)]
|
||||
command: Channels,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Subcommand)]
|
||||
pub enum ServiceAction {
|
||||
/// 前台运行服务
|
||||
Run,
|
||||
/// 后台启动服务
|
||||
Start,
|
||||
/// 停止后台服务
|
||||
Stop,
|
||||
/// 重启后台服务
|
||||
Restart,
|
||||
/// 查看服务运行状态
|
||||
Status,
|
||||
/// 查看后台服务日志
|
||||
Logs {
|
||||
/// 输出最后多少行日志
|
||||
#[arg(short, long, default_value_t = 80)]
|
||||
lines: usize,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Channels {
|
||||
/// 微信渠道配置
|
||||
Wechat {
|
||||
#[command(subcommand)]
|
||||
command: WechatAction,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum WechatAction {
|
||||
/// 登录新的微信账号
|
||||
Login,
|
||||
/// 查看已经登录的微信账号
|
||||
List,
|
||||
/// 删除已登录的微信账号
|
||||
Delete {
|
||||
/// 要删除的微信账号
|
||||
#[arg(short, long)]
|
||||
account: String,
|
||||
},
|
||||
/// 修改账号名称 - 仅做标记,与微信名无关
|
||||
Rename {
|
||||
/// 要修改的微信账号
|
||||
#[arg(short, long)]
|
||||
account: String,
|
||||
/// 名称 仅做标记
|
||||
#[arg(short, long)]
|
||||
name: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum MailAction {
|
||||
/// 引导式配置 IMAP 邮件账户
|
||||
Auth,
|
||||
/// 查看已经配置的邮件账户
|
||||
List,
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
mod cli;
|
||||
|
||||
use clap::Parser;
|
||||
use cli::{Channels, Cli, Commands, MailAction, ServiceAction, WechatAction};
|
||||
use ias_service::{
|
||||
connect_db, delete_account, init_logging, list_accounts, login_user, rename_account,
|
||||
run_service,
|
||||
};
|
||||
use ias_service::supervisor::{
|
||||
print_logs, restart_service, start_service, status_service, stop_service,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenvy::dotenv().ok();
|
||||
init_logging();
|
||||
let cli = Cli::parse();
|
||||
match cli.command {
|
||||
Commands::Service { command } => {
|
||||
let action = command.unwrap_or(ServiceAction::Run);
|
||||
match action {
|
||||
ServiceAction::Run => {
|
||||
let pool = connect_db().await?;
|
||||
run_service(pool).await?;
|
||||
}
|
||||
ServiceAction::Start => start_service().await?,
|
||||
ServiceAction::Stop => stop_service().await?,
|
||||
ServiceAction::Restart => restart_service().await?,
|
||||
ServiceAction::Status => status_service().await?,
|
||||
ServiceAction::Logs { lines } => print_logs(lines)?,
|
||||
}
|
||||
}
|
||||
Commands::Channel { command } => {
|
||||
let pool = connect_db().await?;
|
||||
match command {
|
||||
Channels::Wechat { command } => match command {
|
||||
WechatAction::Login => login_user(&pool).await,
|
||||
WechatAction::List => list_accounts(&pool).await,
|
||||
WechatAction::Delete { account } => delete_account(&pool, account).await,
|
||||
WechatAction::Rename { account, name } => {
|
||||
rename_account(&pool, account, name).await
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Commands::Mail { command } => {
|
||||
let pool = connect_db().await?;
|
||||
match command {
|
||||
MailAction::Auth => ias_mail::auth::auth_account(&pool).await?,
|
||||
MailAction::List => ias_mail::auth::list_accounts(&pool).await?,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user