From d94a10b9498f69b49eb629589906b62eaff31c2d Mon Sep 17 00:00:00 2001 From: "Greg T. Wallace" Date: Fri, 2 Feb 2024 18:35:20 -0500 Subject: [PATCH] cleanup extra args logging / logic --- pkg/app/app.go | 7 ++----- pkg/app/cmd_create.go | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 264e5b9..798f257 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -54,13 +54,10 @@ func Start() { exitCode = 0 app.logger.Info("\n\n", ffhelp.Command(app.cmd)) - } else if errors.Is(err, ErrExtraArgs) { - // extra args (will log elsewhere, so no need to log err again) - app.logger.Info("\n\n", ffhelp.Command(app.cmd)) - } else if errors.Is(err, ff.ErrDuplicateFlag) || errors.Is(err, ff.ErrUnknownFlag) || - errors.Is(err, ff.ErrNoExec) { + errors.Is(err, ff.ErrNoExec) || + errors.Is(err, ErrExtraArgs) { // other error that suggests user needs to see help app.logger.Error(err) app.logger.Info("\n\n", ffhelp.Command(app.cmd)) diff --git a/pkg/app/cmd_create.go b/pkg/app/cmd_create.go index d5ff2a6..2cd0e74 100644 --- a/pkg/app/cmd_create.go +++ b/pkg/app/cmd_create.go @@ -15,8 +15,7 @@ const createDefaultOutFilePath = "apctool.p15" func (app *app) cmdCreate(_ context.Context, args []string) error { // extra args == error if len(args) != 0 { - app.logger.Errorf("create: failed, extra args (%d) present", len(args)) - return ErrExtraArgs + return fmt.Errorf("create: failed, %w (%d)", ErrExtraArgs, len(args)) } // key must be specified