diff --git a/cmd/server/admin.go b/cmd/server/admin.go index d6b31e5..3d70144 100644 --- a/cmd/server/admin.go +++ b/cmd/server/admin.go @@ -6,6 +6,7 @@ import ( "os" "strings" "syscall" + "xmr-remote-nodes/cmd" "xmr-remote-nodes/internal/database" "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 { admin := repo.NewAdminRepo(database.GetDB()) a := repo.Admin{ diff --git a/cmd/server/import.go b/cmd/server/import.go index 7fce9f6..7df335d 100644 --- a/cmd/server/import.go +++ b/cmd/server/import.go @@ -25,7 +25,7 @@ type importData struct { DateEntered int `json:"date_entered"` } -var ImportCmd = &cobra.Command{ +var importCmd = &cobra.Command{ Use: "import", Short: "Import Monero nodes from old API", Long: `Import Monero nodes from old API. diff --git a/cmd/server/probers.go b/cmd/server/probers.go index b4ab49f..5df4d61 100644 --- a/cmd/server/probers.go +++ b/cmd/server/probers.go @@ -6,7 +6,6 @@ import ( "strings" "text/tabwriter" "time" - "xmr-remote-nodes/cmd" "xmr-remote-nodes/internal/database" "xmr-remote-nodes/internal/repo" @@ -15,7 +14,7 @@ import ( var probersCmd = &cobra.Command{ 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. 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{ Use: "add [name]", - Short: "[server] Add new prober", + Short: "Add new prober", Long: `Add new prober machine.`, Run: func(cmd *cobra.Command, args []string) { 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") -} diff --git a/cmd/server/serve.go b/cmd/server/serve.go index c91b8f5..1939795 100644 --- a/cmd/server/serve.go +++ b/cmd/server/serve.go @@ -21,7 +21,7 @@ import ( "github.com/spf13/cobra" ) -var ServeCmd = &cobra.Command{ +var serveCmd = &cobra.Command{ Use: "serve", Short: "Serve the WebUI", Long: `This command will run HTTP server for APIs and WebUI.`, diff --git a/server.go b/server.go index e535bd0..dbd989d 100644 --- a/server.go +++ b/server.go @@ -9,6 +9,4 @@ import ( func init() { cmd.Root.AddCommand(server.AdminCmd) - cmd.Root.AddCommand(server.ServeCmd) - cmd.Root.AddCommand(server.ImportCmd) }