From 5947c69ba42fd305ed485dbaa35f88069646fe09 Mon Sep 17 00:00:00 2001 From: iamrajatrana Date: Thu, 20 Aug 2026 01:43:03 +0530 Subject: [PATCH] fix(cli): reject arguments to plugin list (#334) Signed-off-by: iamrajatrana --- cli/cmd/plugin/list.go | 1 + cli/cmd/plugin/list_test.go | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 cli/cmd/plugin/list_test.go diff --git a/cli/cmd/plugin/list.go b/cli/cmd/plugin/list.go index 14a2d55a..58352ed4 100644 --- a/cli/cmd/plugin/list.go +++ b/cli/cmd/plugin/list.go @@ -30,6 +30,7 @@ import ( var listCmd = &cobra.Command{ Use: "list", Short: "List installed plugins", + Args: cobra.NoArgs, // TODO(P1): cross-reference against the embedded plugin registry to show // latest available versions and update indicators once registry embedding // (F4) is implemented. diff --git a/cli/cmd/plugin/list_test.go b/cli/cmd/plugin/list_test.go new file mode 100644 index 00000000..f23a7e72 --- /dev/null +++ b/cli/cmd/plugin/list_test.go @@ -0,0 +1,50 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plugin + +import "testing" + +func TestListArgs(t *testing.T) { + tests := []struct { + name string + args []string + wantErr bool + }{ + { + name: "no arguments", + }, + { + name: "one argument", + args: []string{"unexpected"}, + wantErr: true, + }, + { + name: "multiple arguments", + args: []string{"one", "two"}, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := listCmd.ValidateArgs(tt.args) + if (err != nil) != tt.wantErr { + t.Fatalf("ValidateArgs(%q) error = %v, wantErr %v", tt.args, err, tt.wantErr) + } + }) + } +}