| 57 | } |
| 58 | |
| 59 | func newShellThumbnailTypeHandler(c types.SM) (TypeHandler, error) { |
| 60 | shell := c["shell"] |
| 61 | mimeType := c["mime-type"] |
| 62 | writeContent := c.GetBool("write-content") |
| 63 | if strings.TrimSpace(shell) == "" { |
| 64 | return nil, errors.New("invalid command, you must specify a valid 'shell'") |
| 65 | } |
| 66 | if mimeType == "" { |
| 67 | return nil, errors.New("mime-type must be specified") |
| 68 | } |
| 69 | command, args := platformShellCommand(runtime.GOOS, shell) |
| 70 | |
| 71 | return &shellThumbnailTypeHandler{ |
| 72 | command: command, |
| 73 | args: args, |
| 74 | writeContent: writeContent, |
| 75 | maxSize: c.GetInt64("max-size", -1), |
| 76 | mimeType: mimeType, |
| 77 | timeout: c.GetDuration("timeout", -1), |
| 78 | }, nil |
| 79 | } |
| 80 | |
| 81 | func platformShellCommand(goos, script string) (string, []string) { |
| 82 | if goos == "windows" { |