| 15 | } |
| 16 | |
| 17 | export function parsePluginArgs(args?: string): ParsedCommand { |
| 18 | if (!args) { |
| 19 | return { type: 'menu' } |
| 20 | } |
| 21 | |
| 22 | const parts = args.trim().split(/\s+/) |
| 23 | const command = parts[0]?.toLowerCase() |
| 24 | |
| 25 | switch (command) { |
| 26 | case 'help': |
| 27 | case '--help': |
| 28 | case '-h': |
| 29 | return { type: 'help' } |
| 30 | |
| 31 | case 'install': |
| 32 | case 'i': { |
| 33 | const target = parts[1] |
| 34 | if (!target) { |
| 35 | return { type: 'install' } |
| 36 | } |
| 37 | |
| 38 | // Check if it's in format plugin@marketplace |
| 39 | if (target.includes('@')) { |
| 40 | const [plugin, marketplace] = target.split('@') |
| 41 | return { type: 'install', plugin, marketplace } |
| 42 | } |
| 43 | |
| 44 | // Check if the target looks like a marketplace (URL or path) |
| 45 | const isMarketplace = |
| 46 | target.startsWith('http://') || |
| 47 | target.startsWith('https://') || |
| 48 | target.startsWith('file://') || |
| 49 | target.includes('/') || |
| 50 | target.includes('\\') |
| 51 | |
| 52 | if (isMarketplace) { |
| 53 | // This is a marketplace URL/path, no plugin specified |
| 54 | return { type: 'install', marketplace: target } |
| 55 | } |
| 56 | |
| 57 | // Otherwise treat it as a plugin name |
| 58 | return { type: 'install', plugin: target } |
| 59 | } |
| 60 | |
| 61 | case 'manage': |
| 62 | return { type: 'manage' } |
| 63 | |
| 64 | case 'uninstall': |
| 65 | return { type: 'uninstall', plugin: parts[1] } |
| 66 | |
| 67 | case 'enable': |
| 68 | return { type: 'enable', plugin: parts[1] } |
| 69 | |
| 70 | case 'disable': |
| 71 | return { type: 'disable', plugin: parts[1] } |
| 72 | |
| 73 | case 'validate': { |
| 74 | const target = parts.slice(1).join(' ').trim() |