From bee4ed305e5dada1e434a00efa9b9c42e89b3271 Mon Sep 17 00:00:00 2001 From: vxclutch Date: Wed, 24 Jun 2026 14:19:00 -0400 Subject: [PATCH] If no argument is provided default to . --- main.go | 10 +++++----- server/restart.go | 5 ++++- server/shell.go | 10 ++++++++-- server/start.go | 6 +++++- server/status.go | 5 ++++- server/stop.go | 6 +++++- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 80fc1d6..b5dd95a 100644 --- a/main.go +++ b/main.go @@ -29,28 +29,28 @@ var startCmd = &cobra.Command{ Use: "start", Short: "Start the minecraft server", Run: server.Start, - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), } var stopCmd = &cobra.Command{ Use: "stop", Short: "Stop the minecraft server", Run: server.Stop, - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), } var restartCmd = &cobra.Command{ Use: "restart", Short: "Restart the minecraft server", Run: server.Restart, - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), } var shellCmd = &cobra.Command{ Use: "shell", Short: "Access RCON shell", Run: server.Shell, - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), } var sayCmd = &cobra.Command{ @@ -64,7 +64,7 @@ var statusCmd = &cobra.Command{ Use: "status", Short: "Get the status of the server", Run: server.Status, - Args: cobra.MinimumNArgs(1), + Args: cobra.MaximumNArgs(1), } //go:embed templates/docker-compose.yml diff --git a/server/restart.go b/server/restart.go index 32d7534..b007cd2 100644 --- a/server/restart.go +++ b/server/restart.go @@ -9,7 +9,10 @@ import ( ) func Restart(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } if err := os.Chdir(dir); err != nil { log.Fatal(err) } diff --git a/server/shell.go b/server/shell.go index 8ce2310..52e0530 100644 --- a/server/shell.go +++ b/server/shell.go @@ -9,7 +9,10 @@ import ( ) func Shell(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } name := getServerName(dir) @@ -20,7 +23,10 @@ func Shell(cmd *cobra.Command, args []string) { } func Say(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } name := getServerName(dir) diff --git a/server/start.go b/server/start.go index 40efadb..fa515c1 100644 --- a/server/start.go +++ b/server/start.go @@ -9,7 +9,11 @@ import ( ) func Start(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } + if err := os.Chdir(dir); err != nil { log.Fatal(err) } diff --git a/server/status.go b/server/status.go index 2f57a1f..8adbb00 100644 --- a/server/status.go +++ b/server/status.go @@ -9,7 +9,10 @@ import ( ) func Status(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } name := getServerName(dir) diff --git a/server/stop.go b/server/stop.go index 204dbcc..96ba5e3 100644 --- a/server/stop.go +++ b/server/stop.go @@ -9,7 +9,11 @@ import ( ) func Stop(cmd *cobra.Command, args []string) { - dir := args[0] + dir := "." + if len(args) > 0 { + dir = args[0] + } + if err := os.Chdir(dir); err != nil { log.Fatal(err) }