diff --git a/cmd/kraft/pkg/pkg.go b/cmd/kraft/pkg/pkg.go index 348024c5e..7c95eed26 100644 --- a/cmd/kraft/pkg/pkg.go +++ b/cmd/kraft/pkg/pkg.go @@ -229,6 +229,19 @@ func (opts *Pkg) Run(cmd *cobra.Command, args []string) error { } } + if len(tree) == 0 { + switch true { + case len(opts.Target) > 0: + return fmt.Errorf("no matching targets found for: %s", opts.Target) + case len(opts.Architecture) > 0 && len(opts.Platform) == 0: + return fmt.Errorf("no matching targets found for architecture: %s", opts.Architecture) + case len(opts.Architecture) == 0 && len(opts.Platform) > 0: + return fmt.Errorf("no matching targets found for platform: %s", opts.Platform) + default: + return fmt.Errorf("no matching targets found for: %s/%s", opts.Platform, opts.Architecture) + } + } + model, err := processtree.NewProcessTree( ctx, []processtree.ProcessTreeOption{ diff --git a/tui/processtree/processtree.go b/tui/processtree/processtree.go index 981e04fe4..1010c666e 100644 --- a/tui/processtree/processtree.go +++ b/tui/processtree/processtree.go @@ -6,6 +6,7 @@ package processtree import ( "context" + "fmt" "os" "strings" "time" @@ -77,6 +78,10 @@ type ProcessTree struct { } func NewProcessTree(ctx context.Context, opts []ProcessTreeOption, tree ...*ProcessTreeItem) (*ProcessTree, error) { + if len(tree) == 0 { + return nil, fmt.Errorf("cannot instantiate process tree without sub processes") + } + pt := &ProcessTree{ tree: tree, ctx: ctx,