mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-17 21:27:52 +02:00
[#82] removed version cmd and make use of cobra.Version
This commit is contained in:
parent
320d1482a4
commit
ce857985be
@ -1,21 +0,0 @@
|
||||
// Package cmd implements various PocketBase system commands.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewVersionCommand creates and returns new command that prints
|
||||
// the current PocketBase version.
|
||||
func NewVersionCommand(app core.App, version string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Prints the current PocketBase app version",
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
fmt.Printf("PocketBase %s\n", version)
|
||||
},
|
||||
}
|
||||
}
|
@ -73,11 +73,16 @@ func New() *PocketBase {
|
||||
|
||||
pb := &PocketBase{
|
||||
RootCmd: &cobra.Command{
|
||||
Use: "pocketbase",
|
||||
Short: "PocketBase CLI",
|
||||
Use: "pocketbase",
|
||||
Short: "PocketBase CLI",
|
||||
Version: Version,
|
||||
FParseErrWhitelist: cobra.FParseErrWhitelist{
|
||||
UnknownFlags: true,
|
||||
},
|
||||
// no need to provide the default cobra completion command
|
||||
CompletionOptions: cobra.CompletionOptions{
|
||||
DisableDefaultCmd: true,
|
||||
},
|
||||
},
|
||||
defaultDebug: withGoRun,
|
||||
defaultDataDir: defaultDir,
|
||||
@ -85,9 +90,6 @@ func New() *PocketBase {
|
||||
showStartBanner: true,
|
||||
}
|
||||
|
||||
// no need to provide the default cobra completion command
|
||||
pb.RootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
||||
// parse base flags
|
||||
// (errors are ignored, since the full flags parsing happens on Execute())
|
||||
pb.eagerParseFlags()
|
||||
@ -130,7 +132,6 @@ func (pb *PocketBase) ShowStartBanner(val bool) *PocketBase {
|
||||
func (pb *PocketBase) Start() error {
|
||||
// register system commands
|
||||
pb.RootCmd.AddCommand(cmd.NewServeCommand(pb, pb.showStartBanner))
|
||||
pb.RootCmd.AddCommand(cmd.NewVersionCommand(pb, Version))
|
||||
pb.RootCmd.AddCommand(cmd.NewMigrateCommand(pb))
|
||||
|
||||
return pb.Execute()
|
||||
|
Loading…
x
Reference in New Issue
Block a user