Allow pasting registry token directly in TUI
When publishing without a configured token, the TUI now: 1. Shows instructions for getting a token 2. Opens an input dialog to paste the token 3. Saves the token and continues with publishing This eliminates the need to exit the TUI or use another terminal. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d09c3f912
commit
0462750b88
|
|
@ -402,21 +402,48 @@ class CmdForgeUI:
|
|||
on_version
|
||||
)
|
||||
|
||||
def _prompt_for_token(self, tool, version):
|
||||
"""Prompt user to enter their registry token."""
|
||||
from ..config import set_registry_token
|
||||
|
||||
def on_info_ok():
|
||||
def on_token(token):
|
||||
if token and token.strip():
|
||||
token = token.strip()
|
||||
try:
|
||||
set_registry_token(token)
|
||||
self.message_box(
|
||||
"Token Saved",
|
||||
"Token configured successfully!",
|
||||
callback=lambda: self._do_publish(tool, version)
|
||||
)
|
||||
except Exception as e:
|
||||
self.message_box("Error", f"Failed to save token: {e}")
|
||||
|
||||
self.input_dialog(
|
||||
"Enter Token",
|
||||
"Paste your API token:",
|
||||
"",
|
||||
on_token
|
||||
)
|
||||
|
||||
self.message_box(
|
||||
"Authentication Required",
|
||||
"To publish tools, you need an API token.\n\n"
|
||||
"1. Go to cmdforge.brrd.tech/register\n"
|
||||
"2. Log in and go to Dashboard > Tokens\n"
|
||||
"3. Create a token and copy it\n"
|
||||
"4. Paste it in the next dialog",
|
||||
callback=on_info_ok
|
||||
)
|
||||
|
||||
def _do_publish(self, tool, version):
|
||||
"""Perform the actual publish."""
|
||||
from ..config import load_config, set_registry_token
|
||||
|
||||
config = load_config()
|
||||
if not config.registry.token:
|
||||
self.message_box(
|
||||
"Authentication Required",
|
||||
"No registry token configured.\n\n"
|
||||
"To publish tools:\n"
|
||||
"1. Register at cmdforge.brrd.tech/register\n"
|
||||
"2. Log in and go to Dashboard > Tokens\n"
|
||||
"3. Generate a token\n"
|
||||
"4. Run: cmdforge config set-token <token>"
|
||||
)
|
||||
self._prompt_for_token(tool, version)
|
||||
return
|
||||
|
||||
def do_publish():
|
||||
|
|
|
|||
Loading…
Reference in New Issue