Add disconnect command and fix GUI connection status refresh
- Add `cmdforge config disconnect` command to clear registry token - Fix GUI connection status label not updating after connect - Store status as instance variable instead of local - Add _update_connection_status() method - Call update after connect dialog completes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5e01a335c0
commit
0216d1d77a
|
|
@ -255,6 +255,10 @@ def main():
|
|||
p_cfg_connect.add_argument("username", help="Your CmdForge username")
|
||||
p_cfg_connect.set_defaults(func=cmd_config)
|
||||
|
||||
# config disconnect
|
||||
p_cfg_disconnect = config_sub.add_parser("disconnect", help="Disconnect from registry (clear token)")
|
||||
p_cfg_disconnect.set_defaults(func=cmd_config)
|
||||
|
||||
# Default for config with no subcommand
|
||||
p_config.set_defaults(func=lambda args: cmd_config(args) if args.config_cmd else (setattr(args, 'config_cmd', 'show') or cmd_config(args)))
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,13 @@ def cmd_config(args):
|
|||
return _cmd_config_set(args)
|
||||
elif args.config_cmd == "connect":
|
||||
return _cmd_config_connect(args)
|
||||
elif args.config_cmd == "disconnect":
|
||||
return _cmd_config_disconnect(args)
|
||||
else:
|
||||
print("Config commands:")
|
||||
print(" show Show current configuration")
|
||||
print(" connect <username> Connect this app to your CmdForge account")
|
||||
print(" disconnect Disconnect from registry (clear token)")
|
||||
print(" set-token <token> Set registry authentication token")
|
||||
print(" set <key> <value> Set a configuration value")
|
||||
return 0
|
||||
|
|
@ -165,3 +168,18 @@ def _cmd_config_connect(args):
|
|||
except KeyboardInterrupt:
|
||||
print("\n\nConnection cancelled.")
|
||||
return 1
|
||||
|
||||
|
||||
def _cmd_config_disconnect(args):
|
||||
"""Disconnect from registry by clearing the token."""
|
||||
config = load_config()
|
||||
|
||||
if not config.registry.token:
|
||||
print("Not connected to registry (no token set).")
|
||||
return 0
|
||||
|
||||
# Clear the token
|
||||
set_registry_token(None)
|
||||
print("Disconnected from registry.")
|
||||
print("Token has been cleared from local configuration.")
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -83,14 +83,9 @@ class ToolsPage(QWidget):
|
|||
header_layout.addStretch()
|
||||
|
||||
# Connection status
|
||||
config = load_config()
|
||||
if config.registry.token:
|
||||
status = QLabel("Connected to Registry")
|
||||
status.setStyleSheet("color: #38a169; font-weight: 500;")
|
||||
else:
|
||||
status = QLabel("Not connected")
|
||||
status.setStyleSheet("color: #718096;")
|
||||
header_layout.addWidget(status)
|
||||
self.connection_status = QLabel()
|
||||
self._update_connection_status()
|
||||
header_layout.addWidget(self.connection_status)
|
||||
|
||||
layout.addWidget(header)
|
||||
|
||||
|
|
@ -174,6 +169,16 @@ class ToolsPage(QWidget):
|
|||
|
||||
layout.addWidget(buttons)
|
||||
|
||||
def _update_connection_status(self):
|
||||
"""Update the connection status label."""
|
||||
config = load_config()
|
||||
if config.registry.token:
|
||||
self.connection_status.setText("Connected to Registry")
|
||||
self.connection_status.setStyleSheet("color: #38a169; font-weight: 500;")
|
||||
else:
|
||||
self.connection_status.setText("Not connected")
|
||||
self.connection_status.setStyleSheet("color: #718096;")
|
||||
|
||||
def refresh(self):
|
||||
"""Refresh the tool list."""
|
||||
self.tool_tree.clear()
|
||||
|
|
@ -392,6 +397,7 @@ class ToolsPage(QWidget):
|
|||
dialog = ConnectDialog(self)
|
||||
if dialog.exec():
|
||||
self.refresh()
|
||||
self._update_connection_status()
|
||||
self.main_window.show_status("Connected to registry")
|
||||
# Recreate publish button
|
||||
self.btn_publish.setText("Publish")
|
||||
|
|
|
|||
Loading…
Reference in New Issue