From 54171191986b6efd455d51e55755cf4548ada7cc Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 8 Mar 2022 19:14:18 -0700 Subject: [PATCH] fixes issue where specifying a non existent action doesnt error properly Signed-off-by: Richard Jones --- cmd/dagger/cmd/do.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/dagger/cmd/do.go b/cmd/dagger/cmd/do.go index 2d7e5e3d..4b24d596 100644 --- a/cmd/dagger/cmd/do.go +++ b/cmd/dagger/cmd/do.go @@ -111,6 +111,7 @@ func doHelp(cmd *cobra.Command, _ []string) { errorMsg string loadedMsg string actionLookupPathMsg string + action *plan.Action actions []*plan.Action ) @@ -120,8 +121,13 @@ func doHelp(cmd *cobra.Command, _ []string) { } else { loadedMsg = "Plan loaded from " + planPath actionLookupPath := getTargetPath(cmd.Flags().Args()) - actions = p.Action().FindByPath(actionLookupPath).Children - actionLookupPathMsg = fmt.Sprintf(`%s:`, actionLookupPath.String()) + action = p.Action().FindByPath(actionLookupPath) + if action == nil { + errorMsg = "Error: action not found\n\n" + } else { + actions = action.Children + actionLookupPathMsg = fmt.Sprintf(`%s:`, actionLookupPath.String()) + } } fmt.Printf(`%s%s