lolly/main.go
xfy 909bd405d2 feat(converter,app): 添加 nginx 配置导入功能
- 新增 internal/converter/nginx 解析器和转换器
- main.go 添加 --import/-i 参数支持 nginx 配置导入
- app_test.go 添加导入功能相关测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 17:12:49 +08:00

50 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package main 提供 Lolly 服务器的入口程序。
//
// 该文件包含命令行参数解析和应用程序启动逻辑:
// - 配置文件路径指定(-c/--config
// - 默认配置生成(--generate-config
// - nginx 配置导入(--import/-i
// - 版本信息显示(-v
//
// 使用示例:
//
// lolly -c /etc/lolly.yaml # 使用指定配置启动
// lolly --generate-config -o config.yaml # 生成默认配置
// lolly -v # 显示版本信息
//
// 作者xfy
package main
import (
"flag"
"os"
"rua.plus/lolly/internal/app"
)
func main() {
cfgPath := flag.String("c", "lolly.yaml", "配置文件路径")
cfgPathLong := flag.String("config", "", "配置文件路径(长参数)")
genConfig := flag.Bool("generate-config", false, "生成默认配置")
genConfigShort := flag.Bool("g", false, "生成默认配置(短参数)")
outputPath := flag.String("o", "", "输出文件路径(配合 --generate-config 或 --import")
importPath := flag.String("import", "", "导入 nginx 配置文件")
importPathShort := flag.String("i", "", "导入 nginx 配置文件(短参数)")
showVersion := flag.Bool("v", false, "显示版本")
flag.Parse()
// 合并短参数和长参数
configPath := *cfgPath
if *cfgPathLong != "" {
configPath = *cfgPathLong
}
generate := *genConfig || *genConfigShort
nginxImport := *importPath
if *importPathShort != "" {
nginxImport = *importPathShort
}
os.Exit(app.Run(configPath, generate, *outputPath, nginxImport, *showVersion))
}