connectcmd

package
v0.23.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectDeleteCmd = &cli.Command{
	Name:        "delete",
	Usage:       "Delete connection alias",
	Description: "Delete a given connection alias.",
	Arguments: []cli.Argument{
		&cli.StringArg{
			Name:     "alias",
			Usage:    "The alias to delete",
			Required: true,
		},
	},
	MaxArgs: cli.NoArgs,
	Run: func(ctx context.Context, cmd *cli.Command) error {
		alias := cmd.GetStringArg("alias")

		if cmd.ConfigFile.FileUsed() == "" {
			return fmt.Errorf("No configuration file has been used.")
		}

		cmd.ConfigFile.DeleteKey("client.connection." + alias)
		if err := cmd.ConfigFile.Save(); err != nil {
			return fmt.Errorf("Failed to save config file: %v", err)
		}

		fmt.Printf("Successfully deleted connection '%s'.\n", alias)
		return nil
	},
}
View Source
var ConnectListCmd = &cli.Command{
	Name:        "list",
	Usage:       "List the known connections",
	Description: "Lists all the known connections stored in the local config.",
	MaxArgs:     cli.NoArgs,
	Run: func(ctx context.Context, cmd *cli.Command) error {

		connections := cmd.ConfigFile.GetKeys("client.connection")
		if len(connections) == 0 {
			fmt.Println("No connections found.")
			return nil
		}

		data := [][]string{}
		data = append(data, []string{"Alias", "Server"})

		for _, alias := range connections {
			server, _ := cmd.ConfigFile.GetValue(fmt.Sprintf("client.connection.%s.server", alias))
			serverStr, _ := server.(string)
			data = append(data, []string{alias, serverStr})
		}

		util.PrintTable(data)
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL