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) }, } }
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) }, } }
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) }, } }
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) }, } }