mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-18 04:51:00 +01:00
started with serve command, yet incomplete
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/tlinden/anydb/app"
|
||||
"github.com/tlinden/anydb/cfg"
|
||||
"github.com/tlinden/anydb/output"
|
||||
"github.com/tlinden/anydb/rest"
|
||||
)
|
||||
|
||||
func Set(conf *cfg.Config) *cobra.Command {
|
||||
@@ -311,3 +312,23 @@ func Man(conf *cfg.Config) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func Serve(conf *cfg.Config) *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "serve [-l host:port]",
|
||||
Short: "run REST API listener",
|
||||
Long: `run REST API listener`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// errors at this stage do not cause the usage to be shown
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
rest.Runserver(conf, nil)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVarP(&conf.Listen, "listen", "l", "localhost:8787", "host:port")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ func Execute() {
|
||||
rootCmd.AddCommand(Del(&conf))
|
||||
rootCmd.AddCommand(Export(&conf))
|
||||
rootCmd.AddCommand(Import(&conf))
|
||||
rootCmd.AddCommand(Serve(&conf))
|
||||
rootCmd.AddCommand(Man(&conf))
|
||||
|
||||
err = rootCmd.Execute()
|
||||
|
||||
Reference in New Issue
Block a user