connectcmd

package
v0.46.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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