mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-14 08:58:27 +08:00
Update go cli (#13717)
### What problem does this PR solve? Go cli ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -10,8 +10,21 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create CLI instance
|
||||
cliApp, err := cli.NewCLI()
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
@@ -26,9 +39,18 @@ func main() {
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
// Run CLI
|
||||
if err := cliApp.Run(); err != nil {
|
||||
fmt.Printf("CLI error: %v\n", err)
|
||||
os.Exit(1)
|
||||
// Check if we have a single command to execute
|
||||
if args.Command != "" {
|
||||
// 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