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 <[email protected]>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user