Set ./cmd/server/admin.go as entrypoint to server build

This commit is contained in:
Cristian Ditaputratama 2024-05-18 18:42:32 +07:00
parent 0f7029b939
commit 7b6cfee31d
Signed by: ditatompel
GPG key ID: 31D3D06D77950979
5 changed files with 15 additions and 15 deletions

View file

@ -6,6 +6,7 @@ import (
"os" "os"
"strings" "strings"
"syscall" "syscall"
"xmr-remote-nodes/cmd"
"xmr-remote-nodes/internal/database" "xmr-remote-nodes/internal/database"
"xmr-remote-nodes/internal/repo" "xmr-remote-nodes/internal/repo"
@ -37,6 +38,16 @@ var AdminCmd = &cobra.Command{
}, },
} }
func init() {
cmd.Root.AddCommand(serveCmd)
cmd.Root.AddCommand(importCmd)
cmd.Root.AddCommand(probersCmd)
probersCmd.AddCommand(listProbersCmd)
probersCmd.AddCommand(addProbersCmd)
listProbersCmd.Flags().StringP("sort-by", "s", "last_submit_ts", "Sort by column name, can be id or last_submit_ts")
listProbersCmd.Flags().StringP("sort-dir", "d", "desc", "Sort direction, can be asc or desc")
}
func createAdmin() error { func createAdmin() error {
admin := repo.NewAdminRepo(database.GetDB()) admin := repo.NewAdminRepo(database.GetDB())
a := repo.Admin{ a := repo.Admin{

View file

@ -25,7 +25,7 @@ type importData struct {
DateEntered int `json:"date_entered"` DateEntered int `json:"date_entered"`
} }
var ImportCmd = &cobra.Command{ var importCmd = &cobra.Command{
Use: "import", Use: "import",
Short: "Import Monero nodes from old API", Short: "Import Monero nodes from old API",
Long: `Import Monero nodes from old API. Long: `Import Monero nodes from old API.

View file

@ -6,7 +6,6 @@ import (
"strings" "strings"
"text/tabwriter" "text/tabwriter"
"time" "time"
"xmr-remote-nodes/cmd"
"xmr-remote-nodes/internal/database" "xmr-remote-nodes/internal/database"
"xmr-remote-nodes/internal/repo" "xmr-remote-nodes/internal/repo"
@ -15,7 +14,7 @@ import (
var probersCmd = &cobra.Command{ var probersCmd = &cobra.Command{
Use: "probers", Use: "probers",
Short: "[server] Add, edit, delete, and show registered probers", Short: "Add, edit, delete, and show registered probers",
Long: `Command to administer prober machines. Long: `Command to administer prober machines.
This command should only be run on the server which directly connect to the MySQL database. This command should only be run on the server which directly connect to the MySQL database.
@ -73,17 +72,9 @@ xmr-nodes probers list -s last_submit_ts -d asc sin1`,
var addProbersCmd = &cobra.Command{ var addProbersCmd = &cobra.Command{
Use: "add [name]", Use: "add [name]",
Short: "[server] Add new prober", Short: "Add new prober",
Long: `Add new prober machine.`, Long: `Add new prober machine.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Println("TODO: Add new prober") fmt.Println("TODO: Add new prober")
}, },
} }
func init() {
cmd.Root.AddCommand(probersCmd)
probersCmd.AddCommand(listProbersCmd)
probersCmd.AddCommand(addProbersCmd)
listProbersCmd.Flags().StringP("sort-by", "s", "last_submit_ts", "Sort by column name, can be id or last_submit_ts")
listProbersCmd.Flags().StringP("sort-dir", "d", "desc", "Sort direction, can be asc or desc")
}

View file

@ -21,7 +21,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var ServeCmd = &cobra.Command{ var serveCmd = &cobra.Command{
Use: "serve", Use: "serve",
Short: "Serve the WebUI", Short: "Serve the WebUI",
Long: `This command will run HTTP server for APIs and WebUI.`, Long: `This command will run HTTP server for APIs and WebUI.`,

View file

@ -9,6 +9,4 @@ import (
func init() { func init() {
cmd.Root.AddCommand(server.AdminCmd) cmd.Root.AddCommand(server.AdminCmd)
cmd.Root.AddCommand(server.ServeCmd)
cmd.Root.AddCommand(server.ImportCmd)
} }