| 19 | ) |
| 20 | |
| 21 | func TestNewCmdList(t *testing.T) { |
| 22 | tests := []struct { |
| 23 | name string |
| 24 | cli string |
| 25 | wantOpts ListOptions |
| 26 | wantJSON bool |
| 27 | wantErr string |
| 28 | }{ |
| 29 | { |
| 30 | name: "no flags", |
| 31 | cli: "", |
| 32 | wantOpts: ListOptions{}, |
| 33 | }, |
| 34 | { |
| 35 | name: "agent and scope filters", |
| 36 | cli: "--agent github-copilot --scope user", |
| 37 | wantOpts: ListOptions{ |
| 38 | Agent: "github-copilot", |
| 39 | Scope: "user", |
| 40 | ScopeChanged: true, |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "custom dir", |
| 45 | cli: "--dir ./skills", |
| 46 | wantOpts: ListOptions{ |
| 47 | Dir: "./skills", |
| 48 | }, |
| 49 | }, |
| 50 | { |
| 51 | name: "json fields", |
| 52 | cli: "--json skillName,sourceURL,scope,version,pinned,path", |
| 53 | wantJSON: true, |
| 54 | }, |
| 55 | { |
| 56 | name: "too many args", |
| 57 | cli: "extra", |
| 58 | wantErr: "unknown command", |
| 59 | }, |
| 60 | { |
| 61 | name: "invalid agent", |
| 62 | cli: "--agent unknown", |
| 63 | wantErr: "invalid argument", |
| 64 | }, |
| 65 | { |
| 66 | name: "invalid scope", |
| 67 | cli: "--scope org", |
| 68 | wantErr: "invalid argument", |
| 69 | }, |
| 70 | { |
| 71 | name: "dir and agent are mutually exclusive", |
| 72 | cli: "--dir ./skills --agent github-copilot", |
| 73 | wantErr: "--dir and --agent cannot be used together", |
| 74 | }, |
| 75 | { |
| 76 | name: "dir and scope are mutually exclusive", |
| 77 | cli: "--dir ./skills --scope user", |
| 78 | wantErr: "--dir and --scope cannot be used together", |