resetEncoding is the generic executor for the encoding-reset commands
(c *grumble.Context, encPtr *util.Encoder)
| 82 | |
| 83 | // resetEncoding is the generic executor for the encoding-reset commands |
| 84 | func resetEncoding(c *grumble.Context, encPtr *util.Encoder) error { |
| 85 | if len(c.Args) != 1 { |
| 86 | return fmt.Errorf("invalid number (%d) of arguments for `encoding %s`", len(c.Args), c.Command.Name) |
| 87 | } |
| 88 | |
| 89 | encoding := c.Args.String("ENCODING") |
| 90 | enc := util.NewEncoder(encoding) |
| 91 | if enc == nil { |
| 92 | return fmt.Errorf("uncognized encoding: %s", encoding) |
| 93 | } |
| 94 | *encPtr = enc |
| 95 | c.App.Println(globalContext) |
| 96 | return nil |
| 97 | } |
| 98 | |
| 99 | func encodingCompleter(prefix string, args []string) []string { |
| 100 | return filterStringWithPrefix(supportedEncodings, prefix) |