Skip to content

Commit d5c548c

Browse files
iapershinalexey-igrychev
authored andcommitted
fix(common): add error handling in case of non-existent command entered
Signed-off-by: Yaroslav Pershin <62902094+iapershin@users.noreply.github.com>
1 parent 6abe5ee commit d5c548c

File tree

3 files changed

+8
-58
lines changed

3 files changed

+8
-58
lines changed

Diff for: cmd/werf/main.go

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88

99
"github.com/sirupsen/logrus"
10+
"github.com/spf13/cobra"
1011

1112
helm_v3 "github.com/werf/3p-helm/cmd/helm"
1213
"github.com/werf/logboek"
@@ -44,6 +45,10 @@ func main() {
4445

4546
root.SetupTelemetryInit(rootCmd)
4647

48+
// WARNING this behaviour could be changed
49+
// https://github.com/spf13/cobra/pull/2167 is not accepted yet
50+
cobra.EnableErrorOnUnknownSubcommand = true
51+
4752
if err := rootCmd.Execute(); err != nil {
4853
if helm_v3.IsPluginError(err) {
4954
common.ShutdownTelemetry(ctx, helm_v3.PluginErrorCode(err))

Diff for: go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -409,4 +409,5 @@ replace (
409409
github.com/deislabs/oras => github.com/werf/3p-oras v0.9.1-0.20240115121544-03962ecbd40a // upstream not maintained
410410
github.com/docker/buildx => github.com/werf/3p-docker-buildx v0.13.0-rc2.0.20241111114615-d77c2e1444ad // upstream not maintained
411411
github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305 // upstream not maintained
412+
github.com/spf13/cobra => github.com/andremueller/cobra v0.0.0-20241025091859-0d550c15a8a4 // remove after merge to upstream
412413
)

0 commit comments

Comments
 (0)