Esempio n. 1
0
func delete(client *clc.Client) cli.Command {
	return cli.Command{
		Name:    "delete",
		Aliases: []string{"d"},
		Usage:   "delete group details",
		Before: func(c *cli.Context) error {
			return util.CheckArgs(c)
		},
		Action: func(c *cli.Context) {
			client, err := util.MaybeLoadConfig(c, client)
			if err != nil {
				fmt.Println(err.Error())
				return
			}
			resp, err := client.Group.Delete(c.Args().First())
			if err != nil {
				fmt.Printf("failed to delete %s", c.Args().First())
				return
			}
			b, err := json.MarshalIndent(resp, "", "  ")
			if err != nil {
				fmt.Printf("%s", err)
				return
			}
			fmt.Printf("%s\n", b)
		},
	}
}
Esempio n. 2
0
func get(client *clc.Client) cli.Command {
	return cli.Command{
		Name:    "get",
		Aliases: []string{"g"},
		Usage:   "get server details",
		Before: func(c *cli.Context) error {
			return util.CheckArgs(c)
		},
		Action: func(c *cli.Context) {
			client, err := util.MaybeLoadConfig(c, client)
			if err != nil {
				fmt.Println(err.Error())
				return
			}
			server, err := client.Server.Get(c.Args().First())
			if err != nil {
				fmt.Printf("failed to get %s\n", c.Args().First())
				return
			}
			b, err := json.MarshalIndent(server, "", "  ")
			if err != nil {
				fmt.Printf("%s", err)
				return
			}
			fmt.Printf("%s\n", b)
		},
	}
}
Esempio n. 3
0
func sshServer(client *clc.Client) cli.Command {
	return cli.Command{
		Name:    "ssh",
		Aliases: []string{"s"},
		Usage:   "ssh to server",
		Before: func(c *cli.Context) error {
			return util.CheckArgs(c)
		},
		Action: func(c *cli.Context) {
			client, err := util.MaybeLoadConfig(c, client)
			if err != nil {
				fmt.Println(err.Error())
				return
			}
			server, err := client.Server.Get(c.Args().First())
			if err != nil {
				fmt.Printf("failed to shh to %s\n", c.Args().First())
				return
			}
			creds, err := client.Server.GetCredentials(c.Args().First())
			if err != nil {
				fmt.Printf("failed to shh to %s\n", c.Args().First())
				return
			}

			internal, err := getInternal(server)
			if err != nil {
				fmt.Printf("failed to shh to %s\n", c.Args().First())
				return
			}

			if err := connect(internal, creds); err != nil {
				fmt.Printf("failed to shh to %s\n", c.Args().First())
				return
			}
		},
	}
}