mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
refactor: tui package for CLI styles and prompts, restyle confirmation
This commit is contained in:
+10
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user