Skip to content

Commit cf084f3

Browse files
committed
feat: install now always prompts restart, add update command
1 parent aab9639 commit cf084f3

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/cli.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,35 @@ function addPlugin(pluginName: string) {
3535
config.plugin = [];
3636
}
3737

38-
if (!config.plugin.includes(pluginName)) {
38+
const existing = config.plugin.includes(pluginName);
39+
if (!existing) {
3940
config.plugin.push(pluginName);
40-
saveConfig(config);
4141
console.log(`✅ Added "${pluginName}" to plugins`);
4242
} else {
43-
console.log(`ℹ️ "${pluginName}" is already in plugins`);
43+
console.log(`ℹ️ "${pluginName}" already in plugins - ensuring latest version`);
4444
}
45+
saveConfig(config);
46+
console.log(`\n📌 Next steps:`);
47+
console.log(` 1. Restart OpenCode to load latest version`);
48+
}
49+
50+
function updatePlugin(pluginName: string) {
51+
const config = getConfig();
52+
53+
if (!config.plugin) {
54+
config.plugin = [];
55+
}
56+
57+
const existing = config.plugin.includes(pluginName);
58+
if (!existing) {
59+
config.plugin.push(pluginName);
60+
console.log(`✅ Added "${pluginName}" to plugins`);
61+
} else {
62+
console.log(`ℹ️ "${pluginName}" already in plugins - forcing reload`);
63+
}
64+
saveConfig(config);
65+
console.log(`\n📌 Next steps:`);
66+
console.log(` 1. Restart OpenCode to load new version`);
4567
}
4668

4769
function removePlugin(pluginName: string) {
@@ -62,10 +84,10 @@ const command = args[0];
6284
switch (command) {
6385
case 'install':
6486
addPlugin('opencode-workaholic');
65-
console.log('\n📌 Next steps:');
66-
console.log(' 1. Restart OpenCode');
67-
console.log(' 2. Run: opencode -c');
68-
console.log(' 3. Verify: workaholic.start, workaholic.status, workaholic.stop');
87+
break;
88+
89+
case 'update':
90+
updatePlugin('opencode-workaholic');
6991
break;
7092

7193
case 'uninstall':
@@ -79,7 +101,8 @@ opencode-workaholic CLI
79101
80102
Usage:
81103
opencode-workaholic install Add plugin to OpenCode config
82-
opencode-workaholic uninstall Remove plugin from OpenCode config
104+
opencode-workaholic update Update plugin (reload even if already installed)
105+
opencode-workaholic uninstall Remove plugin from OpenCode config
83106
84107
Or use directly:
85108
bunx opencode-workaholic@latest install

0 commit comments

Comments
 (0)