diff --git a/cmd/component/action/update.go b/cmd/component/action/update.go index 2d64ef4..c9cf2f9 100644 --- a/cmd/component/action/update.go +++ b/cmd/component/action/update.go @@ -11,6 +11,7 @@ import ( "bunnyshell.com/cli/pkg/config" githelper "bunnyshell.com/cli/pkg/helper/git" "bunnyshell.com/cli/pkg/lib" + "bunnyshell.com/cli/pkg/util" "github.com/spf13/cobra" ) @@ -97,9 +98,10 @@ func init() { flags := command.Flags() - flags.AddFlag(options.ServiceComponent.GetRequiredFlag("id")) - flags.StringVar(&editComponentsData.GitTarget, "git-target", editComponentsData.GitTarget, "Target git spec (e.g. https://github.com/fork/templates@main)") + util.MarkFlagRequiredWithHelp(flags.Lookup("git-target"), "The target git spec (e.g. https://github.com/fork/templates@main)") + + flags.AddFlag(options.ServiceComponent.GetRequiredFlag("id")) flags.BoolVar(&editComponentsData.WithDeploy, "deploy", editComponentsData.WithDeploy, "Deploy the environment after update") flags.StringVar(&editComponentsData.K8SIntegration, "k8s", editComponentsData.K8SIntegration, "Set Kubernetes integration for the environment (if not set)") diff --git a/pkg/helper/git/git_spec.go b/pkg/helper/git/git_spec.go index c767197..eb65033 100644 --- a/pkg/helper/git/git_spec.go +++ b/pkg/helper/git/git_spec.go @@ -1,11 +1,18 @@ package git import ( + "errors" "net/url" "strings" ) +var errEmptySpec = errors.New("empty spec") + func ParseGitSec(spec string) (string, string, error) { + if len(spec) == 0 { + return "", "", errEmptySpec + } + if spec[0] == '@' { return "", spec[1:], nil }