feat: new command line options

This commit is contained in:
Hintay 2025-02-03 00:19:02 +09:00
parent 4e6b2daf0d
commit 4239a89d66
No known key found for this signature in database
GPG key ID: 120FC7FF121F2F2D
4 changed files with 53 additions and 8 deletions

43
internal/cmd/main.go Normal file
View 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
}