diff --git a/cli/internal/validate.go b/cli/internal/validate.go index a2a098282..2a1c0cfaa 100644 --- a/cli/internal/validate.go +++ b/cli/internal/validate.go @@ -2,6 +2,7 @@ package internal import ( "errors" + "strings" "coopcloud.tech/abra/pkg/app" "coopcloud.tech/abra/pkg/catalogue" @@ -111,3 +112,17 @@ func ValidateDomain(c *cli.Context) (string, error) { return domainName, nil } + +// ValidateSubCmdFlags ensures flag order conforms to correct order +func ValidateSubCmdFlags(c *cli.Context) bool { + for argIdx, arg := range c.Args().Slice() { + if !strings.HasPrefix(arg, "--") { + for _, flag := range c.Args().Slice()[argIdx:] { + if strings.HasPrefix(flag, "--") { + return false + } + } + } + } + return true +} diff --git a/cli/server/add.go b/cli/server/add.go index ee5167049..2b8f53101 100644 --- a/cli/server/add.go +++ b/cli/server/add.go @@ -360,6 +360,10 @@ intended as the target server. This is useful when you want to have your entire Co-op Cloud config located on the server itself, and not on your local developer machine. +Example: + + abra server add --local + Otherwise, you may specify a remote server. The argument must be a publicy accessible domain name which points to your server. You should have SSH access to this server, Abra will assume port 22 and will use your current @@ -394,7 +398,7 @@ You may omit flags to avoid performing this provisioning logic. }, ArgsUsage: " [] []", Action: func(c *cli.Context) error { - if c.Args().Len() > 0 && local { + if c.Args().Len() > 0 && local || !internal.ValidateSubCmdFlags(c) { err := errors.New("cannot use '' and '--local' together") internal.ShowSubcommandHelpAndError(c, err) }