MCPcopy Create free account
hub / github.com/Driver-C/tryssh / NewAliasSetCommand

Function NewAliasSetCommand

cmd/alias/set.go:11–32  ·  view source on GitHub ↗

NewAliasSetCommand creates and returns the cobra command for setting an alias.

()

Source from the content-addressed store, hash-verified

9
10// NewAliasSetCommand creates and returns the cobra command for setting an alias.
11func NewAliasSetCommand() *cobra.Command {
12 cmd := &cobra.Command{
13 Use: "set <alias> [flags]",
14 Args: cobra.ExactArgs(1),
15 Short: "Set an alias for the specified server address",
16 Long: "Set an alias for the specified server address",
17 Run: func(cmd *cobra.Command, args []string) {
18 aliasContent := args[0]
19 targetAddress, _ := cmd.Flags().GetString("target")
20 configuration, err := config.LoadConfig()
21 if err != nil {
22 utils.Fatalln(err)
23 }
24 controller := control.NewAliasController(targetAddress, configuration, aliasContent)
25 controller.SetAlias()
26 },
27 }
28 cmd.Flags().StringP(
29 "target", "t", "", "Set the alias for the target server address")
30 _ = cmd.MarkFlagRequired("target")
31 return cmd
32}

Calls 4

SetAliasMethod · 0.95
LoadConfigFunction · 0.92
FatallnFunction · 0.92
NewAliasControllerFunction · 0.92