cmd/cli: ignore empty positional argument for start command

The validation was added during v1.4.0 release, but causing one-liner
install failed unexpectedly.
This commit is contained in:
Cuong Manh Le
2025-07-15 21:47:50 +07:00
committed by Cuong Manh Le
parent 0948161529
commit e616091249

View File

@@ -13,6 +13,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"slices"
"sort"
"strconv"
"strings"
@@ -206,6 +207,9 @@ func initStartCmd() *cobra.Command {
NOTE: running "ctrld start" without any arguments will start already installed ctrld service.`,
Args: func(cmd *cobra.Command, args []string) error {
args = slices.DeleteFunc(args, func(arg string) bool {
return arg == ""
})
if len(args) > 0 {
return fmt.Errorf("'ctrld start' doesn't accept positional arguments\n" +
"Use flags instead (e.g. --cd, --iface) or see 'ctrld start --help' for all options")
@@ -566,6 +570,9 @@ NOTE: running "ctrld start" without any arguments will start already installed c
NOTE: running "ctrld start" without any arguments will start already installed ctrld service.`,
Args: func(cmd *cobra.Command, args []string) error {
args = slices.DeleteFunc(args, func(arg string) bool {
return arg == ""
})
if len(args) > 0 {
return fmt.Errorf("'ctrld start' doesn't accept positional arguments\n" +
"Use flags instead (e.g. --cd, --iface) or see 'ctrld start --help' for all options")