Exemple #1
0
func NewListCommand(client *getch.Client) cli.Command {
	return cli.Command{
		Name:  "list",
		Usage: "List all values stored in Getch for the host where this command is executed from",
		Action: func(c *cli.Context) {
			//in Getch a List is a a normal Get request with the keyword 'list'
			key := "list"
			value := client.Get(key)
			fmt.Print(value)
		},
	}
}
Exemple #2
0
func NewGetCommand(client *getch.Client) cli.Command {
	return cli.Command{
		Name:  "get",
		Usage: "retrieve a value for a given key",
		Action: func(c *cli.Context) {
			if len(c.Args()) == 0 {
				panic("get command requires a key to be queried")
			}
			key := c.Args()[0]
			value := client.Get(key)
			fmt.Print(value)
		},
	}
}
Exemple #3
0
func NewGetFileCommand(client *getch.Client) cli.Command {
	return cli.Command{
		Name:  "getfile",
		Usage: "Downloads the file with the given name from Getch",
		Flags: []cli.Flag{
			cli.StringFlag{"outputfile, o", "", "write the output file with the given name", ""},
		},
		Action: func(c *cli.Context) {
			file := c.Args()[0]
			outputname := c.String("outputfile")
			client.GetFile(file, outputname)
		},
	}
}
Exemple #4
0
func NewEncryptCommand(client *getch.Client) cli.Command {
	return cli.Command{
		Name:  "encrypt",
		Usage: "encrypts a given value so that it can be used in Getch server-side configurations",
		Action: func(c *cli.Context) {
			if len(c.Args()) == 0 {
				panic("encrypt command requires a value to be encrypted")
			}
			value := c.Args()[0]
			encvalue := client.Encrypt(value)
			fmt.Println(encvalue)
		},
	}
}