refactor: tui package for CLI styles and prompts, restyle confirmation

This commit is contained in:
Pasha Sviderski
2026-03-18 16:25:25 +10:00
parent 1735ef9521
commit 68661e57c3
16 changed files with 112 additions and 65 deletions
+10 -2
View File
@@ -71,7 +71,7 @@ func (cli *CLI) SetCurrentContext(name string) error {
return cli.Config.Save()
}
func (cli *CLI) GetContextOverrideOrCurrent() string {
func (cli *CLI) ContextOverrideOrCurrent() string {
if cli.contextOverride != "" {
return cli.contextOverride
}
@@ -81,6 +81,14 @@ func (cli *CLI) GetContextOverrideOrCurrent() string {
return ""
}
// DirectConnection returns the connection string if --connect or UNCLOUD_CONNECT was specified.
func (cli *CLI) DirectConnection() string {
if cli.conn != nil {
return cli.conn.String()
}
return ""
}
// ConnectCluster connects to a cluster using the context override or the current context if not specified.
// If the CLI was initialised with a machine connection, the config is ignored and the connection is used instead.
func (cli *CLI) ConnectCluster(ctx context.Context) (*client.Client, error) {
@@ -316,7 +324,7 @@ type AddMachineOptions struct {
// cluster. The machine client is connected to the new machine and can be used to interact with it.
// Both client should be closed after use by the caller.
func (cli *CLI) AddMachine(ctx context.Context, opts AddMachineOptions) (*client.Client, *client.Client, error) {
contextName := cli.GetContextOverrideOrCurrent()
contextName := cli.ContextOverrideOrCurrent()
c, err := cli.ConnectCluster(ctx)
if err != nil {
return nil, nil, fmt.Errorf("connect to cluster (context '%s'): %w", contextName, err)