mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
feat: new command line options
This commit is contained in:
parent
4e6b2daf0d
commit
4239a89d66
4 changed files with 53 additions and 8 deletions
43
internal/cmd/main.go
Normal file
43
internal/cmd/main.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func NewAppCmd() *cli.Command {
|
||||
serve := false
|
||||
|
||||
cmd := &cli.Command{
|
||||
Name: "nginx-ui",
|
||||
Usage: "Yet another Nginx Web UI",
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "serve",
|
||||
Usage: "Start the Nginx-UI server",
|
||||
Action: func(ctx context.Context, command *cli.Command) error {
|
||||
serve = true
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "config",
|
||||
Value: "app.ini",
|
||||
Usage: "configuration file path",
|
||||
},
|
||||
},
|
||||
DefaultCommand: "serve",
|
||||
}
|
||||
|
||||
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
} else if !serve {
|
||||
os.Exit(0)
|
||||
}
|
||||
return cmd
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue