diff --git a/cli/cmd/pack.go b/cli/cmd/pack.go index c595372f8..014134c54 100644 --- a/cli/cmd/pack.go +++ b/cli/cmd/pack.go @@ -24,29 +24,12 @@ func NewPackCmd() *cobra.Command { The supported types are: tgz, deb, rpm`, ValidArgs: []string{"tgz", "deb", "rpm"}, Run: func(cmd *cobra.Command, args []string) { - err := cobra.ExactArgs(1)(cmd, args) - if err != nil { - err = fmt.Errorf("incorrect combination of command parameters: %s", err.Error()) - log.Fatalf(err.Error()) - } - err = cobra.OnlyValidArgs(cmd, args) - if err != nil { - err = fmt.Errorf("incorrect combination of command parameters: %s", err.Error()) - log.Fatalf(err.Error()) - } - if packCtx.CartridgeCompat && args[0] != "tgz" { - err = fmt.Errorf("cartridge-compat flag can only be used while packing tgz bundle") - log.Fatalf(err.Error()) - } - if packCtx.TarantoolVersion != "" && !packCtx.UseDocker { - err = fmt.Errorf("tarantool-version argument can only be " + - "used while packing in docker") - log.Fatalf(err.Error()) - } cmdCtx.CommandName = cmd.Name() - err = modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalPackModule, args) + err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, + internalPackModule, args) util.HandleCmdErr(cmd, err) }, + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), } // Common flags. @@ -150,6 +133,9 @@ func checkFlags(packCtx *pack.PackCtx) error { log.Warnf("You specified the --all flag," + " but you are not packaging a tarball. Flag will be ignored") } + if packCtx.CartridgeCompat { + return fmt.Errorf("cartridge-compat flag can only be used while packing tgz bundle") + } } // Check if --with-integrity-check and --without-binaries flags are provided // simultaneously. If this is the case, return an error for safety reasons. @@ -157,5 +143,9 @@ func checkFlags(packCtx *pack.PackCtx) error { return fmt.Errorf("impossible combination of --with-integrity-check" + " and --without-binaries flags") } + if packCtx.TarantoolVersion != "" && !packCtx.UseDocker { + return fmt.Errorf("tarantool-version argument can only be " + + "used while packing in docker") + } return nil }