mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-15 20:27:20 +08:00
Feat: add skills space to context engine (#13908)
### What problem does this PR solve? issue #13714 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
66
cmd/cli/ragflow_cli.go
Normal file
66
cmd/cli/ragflow_cli.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"ragflow/internal/cli"
|
||||
"ragflow/internal/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Parse command line arguments (skip program name)
|
||||
args, err := cli.ParseConnectionArgs(os.Args[1:])
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Initialize logger with appropriate level
|
||||
logLevel := "warn" // Default to warn (quiet mode)
|
||||
if args.Verbose {
|
||||
logLevel = "info"
|
||||
}
|
||||
if err := logger.Init(logLevel); err != nil {
|
||||
fmt.Printf("Warning: Failed to initialize logger: %v\n", err)
|
||||
}
|
||||
|
||||
// Show help and exit
|
||||
if args.ShowHelp {
|
||||
cli.PrintUsage()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Create CLI instance with parsed arguments
|
||||
cliApp, err := cli.NewCLIWithArgs(args)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create CLI: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Handle interrupt signal
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigChan
|
||||
cliApp.Cleanup()
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
// Check if we have a single command to execute
|
||||
if args.Command != nil {
|
||||
// Single command mode
|
||||
if err = cliApp.RunSingleCommand(args.Command); err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
// Interactive mode
|
||||
if err = cliApp.Run(); err != nil {
|
||||
fmt.Printf("CLI error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user