@@ -2198,6 +2198,87 @@ func TestRunPrintStreamJSONOutput(t *testing.T) {
21982198 }
21992199}
22002200
2201+ func TestRunPluginCLIUsageForHelpAndUnknown (t * testing.T ) {
2202+ configHome := t .TempDir ()
2203+ t .Setenv ("CLAUDE_CONFIG_DIR" , configHome )
2204+ project := t .TempDir ()
2205+
2206+ tests := []struct {
2207+ name string
2208+ args []string
2209+ wantCode int
2210+ wantStdout []string
2211+ wantStderr []string
2212+ notStderr []string
2213+ }{
2214+ {
2215+ name : "plugin help" ,
2216+ args : []string {"--cwd" , project , "plugin" , "help" },
2217+ wantCode : 0 ,
2218+ wantStdout : []string {"Usage: claude plugin <list|install|update|uninstall|validate|enable|disable|marketplace>" },
2219+ },
2220+ {
2221+ name : "plugin missing" ,
2222+ args : []string {"--cwd" , project , "plugin" },
2223+ wantCode : 2 ,
2224+ wantStderr : []string {"ccgo plugin: missing subcommand" , "Usage: claude plugin <list|install|update|uninstall|validate|enable|disable|marketplace>" },
2225+ notStderr : []string {"unsupported" },
2226+ },
2227+ {
2228+ name : "plugin unknown" ,
2229+ args : []string {"--cwd" , project , "plugin" , "nope" },
2230+ wantCode : 2 ,
2231+ wantStderr : []string {"ccgo plugin: unknown subcommand nope" , "Usage: claude plugin <list|install|update|uninstall|validate|enable|disable|marketplace>" },
2232+ notStderr : []string {"unsupported" },
2233+ },
2234+ {
2235+ name : "marketplace help" ,
2236+ args : []string {"--cwd" , project , "plugin" , "marketplace" , "help" },
2237+ wantCode : 0 ,
2238+ wantStdout : []string {"Usage: claude plugin marketplace <list|add|remove|update|plugins|show>" },
2239+ },
2240+ {
2241+ name : "marketplace missing" ,
2242+ args : []string {"--cwd" , project , "plugin" , "marketplace" },
2243+ wantCode : 2 ,
2244+ wantStderr : []string {"ccgo plugin marketplace: missing subcommand" , "Usage: claude plugin marketplace <list|add|remove|update|plugins|show>" },
2245+ notStderr : []string {"unsupported" },
2246+ },
2247+ {
2248+ name : "marketplace unknown" ,
2249+ args : []string {"--cwd" , project , "plugin" , "marketplace" , "nope" },
2250+ wantCode : 2 ,
2251+ wantStderr : []string {"ccgo plugin marketplace: unknown subcommand nope" , "Usage: claude plugin marketplace <list|add|remove|update|plugins|show>" },
2252+ notStderr : []string {"unsupported" },
2253+ },
2254+ }
2255+
2256+ for _ , tc := range tests {
2257+ t .Run (tc .name , func (t * testing.T ) {
2258+ var stdout , stderr bytes.Buffer
2259+ code := run (tc .args , strings .NewReader ("" ), & stdout , & stderr )
2260+ if code != tc .wantCode {
2261+ t .Fatalf ("exit=%d stdout=%q stderr=%q" , code , stdout .String (), stderr .String ())
2262+ }
2263+ for _ , want := range tc .wantStdout {
2264+ if ! strings .Contains (stdout .String (), want ) {
2265+ t .Fatalf ("stdout missing %q: %q" , want , stdout .String ())
2266+ }
2267+ }
2268+ for _ , want := range tc .wantStderr {
2269+ if ! strings .Contains (stderr .String (), want ) {
2270+ t .Fatalf ("stderr missing %q: %q" , want , stderr .String ())
2271+ }
2272+ }
2273+ for _ , unwanted := range tc .notStderr {
2274+ if strings .Contains (stderr .String (), unwanted ) {
2275+ t .Fatalf ("stderr contains %q: %q" , unwanted , stderr .String ())
2276+ }
2277+ }
2278+ })
2279+ }
2280+ }
2281+
22012282func TestRunPluginListJSONAvailable (t * testing.T ) {
22022283 configHome := t .TempDir ()
22032284 t .Setenv ("CLAUDE_CONFIG_DIR" , configHome )
0 commit comments