[#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)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -75,9 +75,14 @@ func New() *PocketBase {
|
||||||
RootCmd: &cobra.Command{
|
RootCmd: &cobra.Command{
|
||||||
Use: "pocketbase",
|
Use: "pocketbase",
|
||||||
Short: "PocketBase CLI",
|
Short: "PocketBase CLI",
|
||||||
|
Version: Version,
|
||||||
FParseErrWhitelist: cobra.FParseErrWhitelist{
|
FParseErrWhitelist: cobra.FParseErrWhitelist{
|
||||||
UnknownFlags: true,
|
UnknownFlags: true,
|
||||||
},
|
},
|
||||||
|
// no need to provide the default cobra completion command
|
||||||
|
CompletionOptions: cobra.CompletionOptions{
|
||||||
|
DisableDefaultCmd: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
defaultDebug: withGoRun,
|
defaultDebug: withGoRun,
|
||||||
defaultDataDir: defaultDir,
|
defaultDataDir: defaultDir,
|
||||||
|
@ -85,9 +90,6 @@ func New() *PocketBase {
|
||||||
showStartBanner: true,
|
showStartBanner: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to provide the default cobra completion command
|
|
||||||
pb.RootCmd.CompletionOptions.DisableDefaultCmd = true
|
|
||||||
|
|
||||||
// parse base flags
|
// parse base flags
|
||||||
// (errors are ignored, since the full flags parsing happens on Execute())
|
// (errors are ignored, since the full flags parsing happens on Execute())
|
||||||
pb.eagerParseFlags()
|
pb.eagerParseFlags()
|
||||||
|
@ -130,7 +132,6 @@ func (pb *PocketBase) ShowStartBanner(val bool) *PocketBase {
|
||||||
func (pb *PocketBase) Start() error {
|
func (pb *PocketBase) Start() error {
|
||||||
// register system commands
|
// register system commands
|
||||||
pb.RootCmd.AddCommand(cmd.NewServeCommand(pb, pb.showStartBanner))
|
pb.RootCmd.AddCommand(cmd.NewServeCommand(pb, pb.showStartBanner))
|
||||||
pb.RootCmd.AddCommand(cmd.NewVersionCommand(pb, Version))
|
|
||||||
pb.RootCmd.AddCommand(cmd.NewMigrateCommand(pb))
|
pb.RootCmd.AddCommand(cmd.NewMigrateCommand(pb))
|
||||||
|
|
||||||
return pb.Execute()
|
return pb.Execute()
|
||||||
|
|
Loading…
Reference in New Issue